| Index: chrome/test/functional/perf_endure.py
|
| diff --git a/chrome/test/functional/perf_endure.py b/chrome/test/functional/perf_endure.py
|
| index 476f6923a69d3b3f50f855aa1f2bbab3efeb30a7..e647435aff72dd13894531a9618f3165c49ddc81 100755
|
| --- a/chrome/test/functional/perf_endure.py
|
| +++ b/chrome/test/functional/perf_endure.py
|
| @@ -23,12 +23,6 @@ The following variables are related to the Deep Memory Profiler.
|
| Not mandatory.
|
| BUILDBOT_GOT_REVISION: Similar to 'REVISION', but checked only if 'REVISION'
|
| is not specified. Not mandatory.
|
| -
|
| - ENDURE_NO_WPR: Run tests without Web Page Replay if it's set.
|
| - WPR_RECORD: Run tests in record mode. If you want to make a fresh
|
| - archive, make sure to delete the old one, otherwise
|
| - it will append to the old one.
|
| - WPR_ARCHIVE_PATH: an alternative archive file to use.
|
| """
|
|
|
| from datetime import datetime
|
| @@ -48,7 +42,6 @@ import pyauto_utils
|
| import remote_inspector_client
|
| import selenium.common.exceptions
|
| from selenium.webdriver.support.ui import WebDriverWait
|
| -import webpagereplay
|
|
|
|
|
| class NotSupportedEnvironmentError(RuntimeError):
|
| @@ -302,9 +295,6 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
|
| _GSUTIL = 'gsutil'
|
|
|
| def setUp(self):
|
| - # The Web Page Replay environment variables must be parsed before
|
| - # perf.BasePerfTest.setUp()
|
| - self._ParseReplayEnv()
|
| # The environment variables for the Deep Memory Profiler must be set
|
| # before perf.BasePerfTest.setUp() to inherit them to Chrome.
|
| self._dmprof = DeepMemoryProfiler()
|
| @@ -339,7 +329,6 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
|
| self._test_start_time = 0
|
| self._num_errors = 0
|
| self._events_to_output = []
|
| - self._StartReplayServerIfNecessary()
|
|
|
| def tearDown(self):
|
| logging.info('Terminating connection to remote inspector...')
|
| @@ -351,52 +340,9 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
|
| perf.BasePerfTest.tearDown(self)
|
|
|
| # Must be done after perf.BasePerfTest.tearDown()
|
| - self._StopReplayServerIfNecessary()
|
| if self._dmprof:
|
| self._dmprof.TearDown()
|
|
|
| - def _GetArchiveName(self):
|
| - """Return the Web Page Replay archive name that corresponds to a test.
|
| -
|
| - Override this function to return the name of an archive that
|
| - corresponds to the test, e.g "ChromeEndureGmailTest.wpr".
|
| -
|
| - Returns:
|
| - None, by default no archive name is provided.
|
| - """
|
| - return None
|
| -
|
| - def _ParseReplayEnv(self):
|
| - """Parse Web Page Replay related envrionment variables."""
|
| - if 'ENDURE_NO_WPR' in os.environ:
|
| - self._use_wpr = False
|
| - logging.info('Skipping Web Page Replay since ENDURE_NO_WPR is set.')
|
| - else:
|
| - self._archive_path = None
|
| - if 'WPR_ARCHIVE_PATH' in os.environ:
|
| - self._archive_path = os.environ.get('WPR_ARCHIVE_PATH')
|
| - else:
|
| - if self._GetArchiveName():
|
| - self._archive_path = ChromeEndureReplay.Path(
|
| - 'archive', archive_name=self._GetArchiveName())
|
| - self._is_record_mode = 'WPR_RECORD' in os.environ
|
| - if self._is_record_mode:
|
| - if self._archive_path:
|
| - self._use_wpr = True
|
| - else:
|
| - self._use_wpr = False
|
| - logging.info('Fail to record since a valid archive path can not ' +
|
| - 'be generated. Did you implement ' +
|
| - '_GetArchiveName() in your test?')
|
| - else:
|
| - if self._archive_path and os.path.exists(self._archive_path):
|
| - self._use_wpr = True
|
| - else:
|
| - self._use_wpr = False
|
| - logging.info(
|
| - 'Skipping Web Page Replay since archive file %sdoes not exist.',
|
| - self._archive_path + ' ' if self._archive_path else '')
|
| -
|
| def ExtraChromeFlags(self):
|
| """Ensures Chrome is launched with custom flags.
|
|
|
| @@ -415,8 +361,6 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
|
| '--enable-memory-benchmarking']
|
| if deep_memory_profile:
|
| extra_flags.append('--no-sandbox')
|
| - if self._use_wpr:
|
| - extra_flags.extend(ChromeEndureReplay.CHROME_FLAGS)
|
| return perf.BasePerfTest.ExtraChromeFlags(self) + extra_flags
|
|
|
| def _OnTimelineEvent(self, event_info):
|
| @@ -718,26 +662,6 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
|
|
|
| return True
|
|
|
| - def _StartReplayServerIfNecessary(self):
|
| - """Start replay server if necessary."""
|
| - if self._use_wpr:
|
| - mode = 'record' if self._is_record_mode else 'replay'
|
| - self._wpr_server = ChromeEndureReplay.ReplayServer(self._archive_path)
|
| - self._wpr_server.StartServer()
|
| - logging.info('Web Page Replay server has started in %s mode.', mode)
|
| -
|
| - def _StopReplayServerIfNecessary(self):
|
| - """Stop the Web Page Replay server if necessary.
|
| -
|
| - This method has to be called AFTER all network connections which go
|
| - through Web Page Replay server have shut down. Otherwise the
|
| - Web Page Replay server will hang to wait for them. A good
|
| - place is to call it at the end of the teardown process.
|
| - """
|
| - if self._use_wpr:
|
| - self._wpr_server.StopServer()
|
| - logging.info('The Web Page Replay server stopped.')
|
| -
|
|
|
| class ChromeEndureControlTest(ChromeEndureBaseTest):
|
| """Control tests for Chrome Endure."""
|
| @@ -788,511 +712,6 @@ class ChromeEndureControlTest(ChromeEndureBaseTest):
|
| test_description, lambda: scenario(driver))
|
|
|
|
|
| -# TODO(dennisjeffrey): Make new WPR recordings of the Gmail tests so that we
|
| -# can remove the special handling for when self._use_wpr is True.
|
| -class ChromeEndureGmailTest(ChromeEndureBaseTest):
|
| - """Long-running performance tests for Chrome using Gmail."""
|
| -
|
| - _WEBAPP_NAME = 'Gmail'
|
| - _TAB_TITLE_SUBSTRING = 'Gmail'
|
| - _FRAME_XPATH = 'id("canvas_frame")'
|
| -
|
| - def setUp(self):
|
| - ChromeEndureBaseTest.setUp(self)
|
| -
|
| - self._FRAME_XPATH = self._FRAME_XPATH if self._use_wpr else ''
|
| -
|
| - # Log into a test Google account and open up Gmail.
|
| - self._LoginToGoogleAccount(account_key='test_google_account_gmail')
|
| - self.NavigateToURL(self._GetConfig().get('gmail_url'))
|
| - self.assertTrue(
|
| - self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in
|
| - self.GetActiveTabTitle(),
|
| - timeout=60, expect_retval=True, retry_sleep=1),
|
| - msg='Timed out waiting for Gmail to load. Tab title is: %s' %
|
| - self.GetActiveTabTitle())
|
| -
|
| - self._driver = self.NewWebDriver()
|
| - # Any call to wait.until() will raise an exception if the timeout is hit.
|
| - # TODO(dennisjeffrey): Remove the need for webdriver's wait using the new
|
| - # DOM mutation observer mechanism.
|
| - self._wait = WebDriverWait(self._driver, timeout=60)
|
| -
|
| -
|
| - if self._use_wpr:
|
| - # Wait until Gmail's 'canvas_frame' loads and the 'Inbox' link is present.
|
| - # TODO(dennisjeffrey): Check with the Gmail team to see if there's a
|
| - # better way to tell when the webpage is ready for user interaction.
|
| - self._wait.until(
|
| - self._SwitchToCanvasFrame) # Raises exception if the timeout is hit.
|
| -
|
| - # Wait for the inbox to appear.
|
| - self.WaitForDomNode('//a[starts-with(@title, "Inbox")]',
|
| - frame_xpath=self._FRAME_XPATH)
|
| -
|
| - # Test whether latency dom element is available.
|
| - try:
|
| - self._GetLatencyDomElement(5000)
|
| - self._has_latency = True
|
| - except pyauto_errors.JSONInterfaceError:
|
| - logging.info('Skip recording latency as latency ' +
|
| - 'dom element is not available.')
|
| - self._has_latency = False
|
| -
|
| - def _GetArchiveName(self):
|
| - """Return Web Page Replay archive name."""
|
| - return 'ChromeEndureGmailTest.wpr'
|
| -
|
| - def _SwitchToCanvasFrame(self, driver):
|
| - """Switch the WebDriver to Gmail's 'canvas_frame', if it's available.
|
| -
|
| - Args:
|
| - driver: A selenium.webdriver.remote.webdriver.WebDriver object.
|
| -
|
| - Returns:
|
| - True, if the switch to Gmail's 'canvas_frame' is successful, or
|
| - False if not.
|
| - """
|
| - try:
|
| - driver.switch_to_frame('canvas_frame')
|
| - return True
|
| - except selenium.common.exceptions.NoSuchFrameException:
|
| - return False
|
| -
|
| - def _GetLatencyDomElement(self, timeout=-1):
|
| - """Returns a reference to the latency info element in the Gmail DOM.
|
| -
|
| - Args:
|
| - timeout: The maximum amount of time (in milliseconds) to wait for
|
| - the latency dom element to appear, defaults to the
|
| - default automation timeout.
|
| - Returns:
|
| - A latency dom element.
|
| - """
|
| - latency_xpath = (
|
| - '//span[starts-with(text(), "Why was the last action slow?")]')
|
| - self.WaitForDomNode(latency_xpath, timeout=timeout,
|
| - frame_xpath=self._FRAME_XPATH)
|
| - return self._GetElement(self._driver.find_element_by_xpath, latency_xpath)
|
| -
|
| - def _WaitUntilDomElementRemoved(self, dom_element):
|
| - """Waits until the given element is no longer attached to the DOM.
|
| -
|
| - Args:
|
| - dom_element: A selenium.webdriver.remote.WebElement object.
|
| - """
|
| - def _IsElementStale():
|
| - try:
|
| - dom_element.tag_name
|
| - except selenium.common.exceptions.StaleElementReferenceException:
|
| - return True
|
| - return False
|
| -
|
| - self.WaitUntil(_IsElementStale, timeout=60, expect_retval=True)
|
| -
|
| - def _ClickElementAndRecordLatency(self, element, test_description,
|
| - action_description):
|
| - """Clicks a DOM element and records the latency associated with that action.
|
| -
|
| - To account for scenario warm-up time, latency values during the first
|
| - minute of test execution are not recorded.
|
| -
|
| - Args:
|
| - element: A selenium.webdriver.remote.WebElement object to click.
|
| - test_description: A string description of what the test does, used for
|
| - outputting results to be graphed. Should not contain spaces. For
|
| - example, 'ComposeDiscard' for Gmail.
|
| - action_description: A string description of what action is being
|
| - performed. Should not contain spaces. For example, 'Compose'.
|
| - """
|
| - if not self._has_latency:
|
| - element.click()
|
| - return
|
| - latency_dom_element = self._GetLatencyDomElement()
|
| - element.click()
|
| - # Wait for the old latency value to be removed, before getting the new one.
|
| - self._WaitUntilDomElementRemoved(latency_dom_element)
|
| -
|
| - latency_dom_element = self._GetLatencyDomElement()
|
| - match = re.search(r'\[(\d+) ms\]', latency_dom_element.text)
|
| - if match:
|
| - latency = int(match.group(1))
|
| - elapsed_time = int(round(time.time() - self._test_start_time))
|
| - if elapsed_time > 60: # Ignore the first minute of latency measurements.
|
| - self._OutputPerfGraphValue(
|
| - '%sLatency' % action_description, [(elapsed_time, latency)], 'msec',
|
| - graph_name='%s%s-%sLatency' % (self._WEBAPP_NAME, test_description,
|
| - action_description),
|
| - units_x='seconds')
|
| - else:
|
| - logging.warning('Could not identify latency value.')
|
| -
|
| - def testGmailComposeDiscard(self):
|
| - """Continuously composes/discards an e-mail before sending.
|
| -
|
| - This test continually composes/discards an e-mail using Gmail, and
|
| - periodically gathers performance stats that may reveal memory bloat.
|
| - """
|
| - test_description = 'ComposeDiscard'
|
| -
|
| - def scenario_wpr():
|
| - # Click the "Compose" button, enter some text into the "To" field, enter
|
| - # some text into the "Subject" field, then click the "Discard" button to
|
| - # discard the message.
|
| - compose_xpath = '//div[text()="COMPOSE"]'
|
| - self.WaitForDomNode(compose_xpath, frame_xpath=self._FRAME_XPATH)
|
| - compose_button = self._GetElement(self._driver.find_element_by_xpath,
|
| - compose_xpath)
|
| - self._ClickElementAndRecordLatency(
|
| - compose_button, test_description, 'Compose')
|
| -
|
| - to_xpath = '//textarea[@name="to"]'
|
| - self.WaitForDomNode(to_xpath, frame_xpath=self._FRAME_XPATH)
|
| - to_field = self._GetElement(self._driver.find_element_by_xpath, to_xpath)
|
| - to_field.send_keys('nobody@nowhere.com')
|
| -
|
| - subject_xpath = '//input[@name="subject"]'
|
| - self.WaitForDomNode(subject_xpath, frame_xpath=self._FRAME_XPATH)
|
| - subject_field = self._GetElement(self._driver.find_element_by_xpath,
|
| - subject_xpath)
|
| - subject_field.send_keys('This message is about to be discarded')
|
| -
|
| - discard_xpath = '//div[text()="Discard"]'
|
| - self.WaitForDomNode(discard_xpath, frame_xpath=self._FRAME_XPATH)
|
| - discard_button = self._GetElement(self._driver.find_element_by_xpath,
|
| - discard_xpath)
|
| - discard_button.click()
|
| -
|
| - # Wait for the message to be discarded, assumed to be true after the
|
| - # "To" field is removed from the webpage DOM.
|
| - self._wait.until(lambda _: not self._GetElement(
|
| - self._driver.find_element_by_name, 'to'))
|
| -
|
| - def scenario_live():
|
| - compose_xpath = '//div[text()="COMPOSE"]'
|
| - self.WaitForDomNode(compose_xpath, frame_xpath=self._FRAME_XPATH)
|
| - compose_button = self._GetElement(self._driver.find_element_by_xpath,
|
| - compose_xpath)
|
| - self._ClickElementAndRecordLatency(
|
| - compose_button, test_description, 'Compose')
|
| -
|
| - to_xpath = '//textarea[@name="to"]'
|
| - self.WaitForDomNode(to_xpath, frame_xpath=self._FRAME_XPATH)
|
| - to_field = self._GetElement(self._driver.find_element_by_xpath, to_xpath)
|
| - to_field.send_keys('nobody@nowhere.com')
|
| -
|
| - subject_xpath = '//input[@name="subjectbox"]'
|
| - self.WaitForDomNode(subject_xpath, frame_xpath=self._FRAME_XPATH)
|
| - subject_field = self._GetElement(self._driver.find_element_by_xpath,
|
| - subject_xpath)
|
| - subject_field.send_keys('This message is about to be discarded')
|
| -
|
| - discard_xpath = '//div[@aria-label="Discard draft"]'
|
| - self.WaitForDomNode(discard_xpath, frame_xpath=self._FRAME_XPATH)
|
| - discard_button = self._GetElement(self._driver.find_element_by_xpath,
|
| - discard_xpath)
|
| - discard_button.click()
|
| -
|
| - # Wait for the message to be discarded, assumed to be true after the
|
| - # "To" element is removed from the webpage DOM.
|
| - self._wait.until(lambda _: not self._GetElement(
|
| - self._driver.find_element_by_name, 'to'))
|
| -
|
| - scenario = scenario_wpr if self._use_wpr else scenario_live
|
| - self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
|
| - test_description, scenario,
|
| - frame_xpath=self._FRAME_XPATH)
|
| -
|
| - def testGmailAlternateThreadlistConversation(self):
|
| - """Alternates between threadlist view and conversation view.
|
| -
|
| - This test continually clicks between the threadlist (Inbox) and the
|
| - conversation view (e-mail message view), and periodically gathers
|
| - performance stats that may reveal memory bloat.
|
| - """
|
| - test_description = 'ThreadConversation'
|
| -
|
| - def scenario():
|
| - # Click an e-mail to see the conversation view, wait 1 second, click the
|
| - # "Inbox" link to see the threadlist, wait 1 second.
|
| -
|
| - # Find the first thread (e-mail) identified by a "span" tag that contains
|
| - # an "email" attribute. Then click it and wait for the conversation view
|
| - # to appear (assumed to be visible when a particular div exists on the
|
| - # page).
|
| - thread_xpath = '//span[@email]'
|
| - self.WaitForDomNode(thread_xpath, frame_xpath=self._FRAME_XPATH)
|
| - thread = self._GetElement(self._driver.find_element_by_xpath,
|
| - thread_xpath)
|
| - self._ClickElementAndRecordLatency(
|
| - thread, test_description, 'Conversation')
|
| - self.WaitForDomNode('//div[text()="Click here to "]',
|
| - frame_xpath=self._FRAME_XPATH)
|
| - time.sleep(1)
|
| -
|
| - # Find the inbox link and click it. Then wait for the inbox to be shown
|
| - # (assumed to be true when the particular div from the conversation view
|
| - # no longer appears on the page).
|
| - inbox_xpath = '//a[starts-with(text(), "Inbox")]'
|
| - self.WaitForDomNode(inbox_xpath, frame_xpath=self._FRAME_XPATH)
|
| - inbox = self._GetElement(self._driver.find_element_by_xpath, inbox_xpath)
|
| - self._ClickElementAndRecordLatency(inbox, test_description, 'Threadlist')
|
| - self._wait.until(
|
| - lambda _: not self._GetElement(
|
| - self._driver.find_element_by_xpath,
|
| - '//div[text()="Click here to "]'))
|
| - time.sleep(1)
|
| -
|
| - self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
|
| - test_description, scenario,
|
| - frame_xpath=self._FRAME_XPATH)
|
| -
|
| - def testGmailAlternateTwoLabels(self):
|
| - """Continuously alternates between two labels.
|
| -
|
| - This test continually clicks between the "Inbox" and "Sent Mail" labels,
|
| - and periodically gathers performance stats that may reveal memory bloat.
|
| - """
|
| - test_description = 'AlternateLabels'
|
| -
|
| - def scenario():
|
| - # Click the "Sent Mail" label, wait for 1 second, click the "Inbox" label,
|
| - # wait for 1 second.
|
| -
|
| - # Click the "Sent Mail" label, then wait for the tab title to be updated
|
| - # with the substring "sent".
|
| - sent_xpath = '//a[starts-with(text(), "Sent Mail")]'
|
| - self.WaitForDomNode(sent_xpath, frame_xpath=self._FRAME_XPATH)
|
| - sent = self._GetElement(self._driver.find_element_by_xpath, sent_xpath)
|
| - self._ClickElementAndRecordLatency(sent, test_description, 'SentMail')
|
| - self.assertTrue(
|
| - self.WaitUntil(lambda: 'Sent Mail' in self.GetActiveTabTitle(),
|
| - timeout=60, expect_retval=True, retry_sleep=1),
|
| - msg='Timed out waiting for Sent Mail to appear.')
|
| - time.sleep(1)
|
| -
|
| - # Click the "Inbox" label, then wait for the tab title to be updated with
|
| - # the substring "inbox".
|
| - inbox_xpath = '//a[starts-with(text(), "Inbox")]'
|
| - self.WaitForDomNode(inbox_xpath, frame_xpath=self._FRAME_XPATH)
|
| - inbox = self._GetElement(self._driver.find_element_by_xpath, inbox_xpath)
|
| - self._ClickElementAndRecordLatency(inbox, test_description, 'Inbox')
|
| - self.assertTrue(
|
| - self.WaitUntil(lambda: 'Inbox' in self.GetActiveTabTitle(),
|
| - timeout=60, expect_retval=True, retry_sleep=1),
|
| - msg='Timed out waiting for Inbox to appear.')
|
| - time.sleep(1)
|
| -
|
| - self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
|
| - test_description, scenario,
|
| - frame_xpath=self._FRAME_XPATH)
|
| -
|
| - def testGmailExpandCollapseConversation(self):
|
| - """Continuously expands/collapses all messages in a conversation.
|
| -
|
| - This test opens up a conversation (e-mail thread) with several messages,
|
| - then continually alternates between the "Expand all" and "Collapse all"
|
| - views, while periodically gathering performance stats that may reveal memory
|
| - bloat.
|
| - """
|
| - test_description = 'ExpandCollapse'
|
| -
|
| - # Enter conversation view for a particular thread.
|
| - thread_xpath = '//span[@email]'
|
| - self.WaitForDomNode(thread_xpath, frame_xpath=self._FRAME_XPATH)
|
| - thread = self._GetElement(self._driver.find_element_by_xpath, thread_xpath)
|
| - thread.click()
|
| - self.WaitForDomNode('//div[text()="Click here to "]',
|
| - frame_xpath=self._FRAME_XPATH)
|
| -
|
| - def scenario():
|
| - # Click on the "Expand all" icon, wait for 1 second, click on the
|
| - # "Collapse all" icon, wait for 1 second.
|
| -
|
| - # Click the "Expand all" icon, then wait for that icon to be removed from
|
| - # the page.
|
| - expand_xpath = '//img[@alt="Expand all"]'
|
| - self.WaitForDomNode(expand_xpath, frame_xpath=self._FRAME_XPATH)
|
| - expand = self._GetElement(self._driver.find_element_by_xpath,
|
| - expand_xpath)
|
| - self._ClickElementAndRecordLatency(expand, test_description, 'ExpandAll')
|
| - self.WaitForDomNode(
|
| - '//img[@alt="Expand all"]/parent::*/parent::*/parent::*'
|
| - '[@style="display: none;"]',
|
| - frame_xpath=self._FRAME_XPATH)
|
| - time.sleep(1)
|
| -
|
| - # Click the "Collapse all" icon, then wait for that icon to be removed
|
| - # from the page.
|
| - collapse_xpath = '//img[@alt="Collapse all"]'
|
| - self.WaitForDomNode(collapse_xpath, frame_xpath=self._FRAME_XPATH)
|
| - collapse = self._GetElement(self._driver.find_element_by_xpath,
|
| - collapse_xpath)
|
| - collapse.click()
|
| - self.WaitForDomNode(
|
| - '//img[@alt="Collapse all"]/parent::*/parent::*/parent::*'
|
| - '[@style="display: none;"]',
|
| - frame_xpath=self._FRAME_XPATH)
|
| - time.sleep(1)
|
| -
|
| - self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
|
| - test_description, scenario,
|
| - frame_xpath=self._FRAME_XPATH)
|
| -
|
| -
|
| -class ChromeEndureDocsTest(ChromeEndureBaseTest):
|
| - """Long-running performance tests for Chrome using Google Docs."""
|
| -
|
| - _WEBAPP_NAME = 'Docs'
|
| - _TAB_TITLE_SUBSTRING = 'Google Drive'
|
| -
|
| - def setUp(self):
|
| - ChromeEndureBaseTest.setUp(self)
|
| -
|
| - # Log into a test Google account and open up Google Docs.
|
| - self._LoginToGoogleAccount()
|
| - self.NavigateToURL(self._GetConfig().get('docs_url'))
|
| - self.assertTrue(
|
| - self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in
|
| - self.GetActiveTabTitle(),
|
| - timeout=60, expect_retval=True, retry_sleep=1),
|
| - msg='Timed out waiting for Docs to load. Tab title is: %s' %
|
| - self.GetActiveTabTitle())
|
| -
|
| - self._driver = self.NewWebDriver()
|
| -
|
| - def _GetArchiveName(self):
|
| - """Return Web Page Replay archive name."""
|
| - return 'ChromeEndureDocsTest.wpr'
|
| -
|
| - def testDocsAlternatelyClickLists(self):
|
| - """Alternates between two different document lists.
|
| -
|
| - This test alternately clicks the "Shared with me" and "My Drive" buttons in
|
| - Google Docs, and periodically gathers performance stats that may reveal
|
| - memory bloat.
|
| - """
|
| - test_description = 'AlternateLists'
|
| -
|
| - def sort_menu_setup():
|
| - # Open and close the "Sort" menu to get some DOM nodes to appear that are
|
| - # used by the scenario in this test.
|
| - sort_xpath = '//div[text()="Sort"]'
|
| - self.WaitForDomNode(sort_xpath)
|
| - sort_button = self._GetElement(self._driver.find_element_by_xpath,
|
| - sort_xpath)
|
| - sort_button.click()
|
| - sort_button.click()
|
| - sort_button.click()
|
| -
|
| - def scenario():
|
| - # Click the "Shared with me" button, wait for 1 second, click the
|
| - # "My Drive" button, wait for 1 second.
|
| -
|
| - # Click the "Shared with me" button and wait for a div to appear.
|
| - if not self._ClickElementByXpath(
|
| - self._driver, '//div[text()="Shared with me"]'):
|
| - self._num_errors += 1
|
| - logging.warning('Logging an automation error: click "shared with me".')
|
| - try:
|
| - self.WaitForDomNode('//div[text()="Share date"]')
|
| - except pyauto_errors.JSONInterfaceError:
|
| - # This case can occur when the page reloads; set things up again.
|
| - sort_menu_setup()
|
| - time.sleep(1)
|
| -
|
| - # Click the "My Drive" button and wait for a resulting div to appear.
|
| - if not self._ClickElementByXpath(
|
| - self._driver, '//span[starts-with(text(), "My Drive")]'):
|
| - self._num_errors += 1
|
| - logging.warning('Logging an automation error: click "my drive".')
|
| - try:
|
| - self.WaitForDomNode('//div[text()="Quota used"]')
|
| - except pyauto_errors.JSONInterfaceError:
|
| - # This case can occur when the page reloads; set things up again.
|
| - sort_menu_setup()
|
| - time.sleep(1)
|
| -
|
| - sort_menu_setup()
|
| -
|
| - self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
|
| - test_description, scenario)
|
| -
|
| -
|
| -class ChromeEndurePlusTest(ChromeEndureBaseTest):
|
| - """Long-running performance tests for Chrome using Google Plus."""
|
| -
|
| - _WEBAPP_NAME = 'Plus'
|
| - _TAB_TITLE_SUBSTRING = 'Google+'
|
| -
|
| - def setUp(self):
|
| - ChromeEndureBaseTest.setUp(self)
|
| -
|
| - # Log into a test Google account and open up Google Plus.
|
| - self._LoginToGoogleAccount()
|
| - self.NavigateToURL(self._GetConfig().get('plus_url'))
|
| - loaded_tab_title = self.GetActiveTabTitle()
|
| - self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title,
|
| - msg='Loaded tab title does not contain "%s": "%s"' %
|
| - (self._TAB_TITLE_SUBSTRING, loaded_tab_title))
|
| -
|
| - self._driver = self.NewWebDriver()
|
| -
|
| - def _GetArchiveName(self):
|
| - """Return Web Page Replay archive name."""
|
| - return 'ChromeEndurePlusTest.wpr'
|
| -
|
| - def testPlusAlternatelyClickStreams(self):
|
| - """Alternates between two different streams.
|
| -
|
| - This test alternately clicks the "Friends" and "Family" buttons using
|
| - Google Plus, and periodically gathers performance stats that may reveal
|
| - memory bloat.
|
| - """
|
| - test_description = 'AlternateStreams'
|
| -
|
| - def scenario():
|
| - # Click the "Friends" button, wait for 1 second, click the "Family"
|
| - # button, wait for 1 second.
|
| -
|
| - # Click the "Friends" button and wait for a resulting div to appear.
|
| - if not self._ClickElementByXpath(
|
| - self._driver,
|
| - '//div[text()="Friends" and '
|
| - 'starts-with(@data-dest, "stream/circles")]'):
|
| - self._num_errors += 1
|
| - logging.warning('Logging an automation error: click "Friends" button.')
|
| -
|
| - try:
|
| - self.WaitForDomNode('//span[contains(., "in Friends")]')
|
| - except (pyauto_errors.JSONInterfaceError,
|
| - pyauto_errors.JavascriptRuntimeError):
|
| - self._num_errors += 1
|
| - logging.warning('Logging an automation error: wait for "in Friends".')
|
| -
|
| - time.sleep(1)
|
| -
|
| - # Click the "Family" button and wait for a resulting div to appear.
|
| - if not self._ClickElementByXpath(
|
| - self._driver,
|
| - '//div[text()="Family" and '
|
| - 'starts-with(@data-dest, "stream/circles")]'):
|
| - self._num_errors += 1
|
| - logging.warning('Logging an automation error: click "Family" button.')
|
| -
|
| - try:
|
| - self.WaitForDomNode('//span[contains(., "in Family")]')
|
| - except (pyauto_errors.JSONInterfaceError,
|
| - pyauto_errors.JavascriptRuntimeError):
|
| - self._num_errors += 1
|
| - logging.warning('Logging an automation error: wait for "in Family".')
|
| -
|
| - time.sleep(1)
|
| -
|
| - self._RunEndureTest(self._WEBAPP_NAME, self._TAB_TITLE_SUBSTRING,
|
| - test_description, scenario)
|
| -
|
| -
|
| class IndexedDBOfflineTest(ChromeEndureBaseTest):
|
| """Long-running performance tests for IndexedDB, modeling offline usage."""
|
|
|
| @@ -1353,46 +772,5 @@ class IndexedDBOfflineTest(ChromeEndureBaseTest):
|
| test_description, scenario)
|
|
|
|
|
| -class ChromeEndureReplay(object):
|
| - """Run Chrome Endure tests with network simulation via Web Page Replay."""
|
| -
|
| - _PATHS = {
|
| - 'archive':
|
| - 'src/chrome/test/data/pyauto_private/webpagereplay/{archive_name}',
|
| - 'scripts':
|
| - 'src/chrome/test/data/chrome_endure/webpagereplay/wpr_deterministic.js',
|
| - }
|
| -
|
| - WEBPAGEREPLAY_HOST = '127.0.0.1'
|
| - WEBPAGEREPLAY_HTTP_PORT = 8080
|
| - WEBPAGEREPLAY_HTTPS_PORT = 8413
|
| -
|
| - CHROME_FLAGS = webpagereplay.GetChromeFlags(
|
| - WEBPAGEREPLAY_HOST,
|
| - WEBPAGEREPLAY_HTTP_PORT,
|
| - WEBPAGEREPLAY_HTTPS_PORT)
|
| -
|
| - @classmethod
|
| - def Path(cls, key, **kwargs):
|
| - return perf.FormatChromePath(cls._PATHS[key], **kwargs)
|
| -
|
| - @classmethod
|
| - def ReplayServer(cls, archive_path):
|
| - """Create a replay server."""
|
| - # Inject customized scripts for Google webapps.
|
| - # See the javascript file for details.
|
| - scripts = cls.Path('scripts')
|
| - if not os.path.exists(scripts):
|
| - raise IOError('Injected scripts %s not found.' % scripts)
|
| - replay_options = ['--inject_scripts', scripts]
|
| - if 'WPR_RECORD' in os.environ:
|
| - replay_options.append('--append')
|
| - return webpagereplay.ReplayServer(archive_path,
|
| - cls.WEBPAGEREPLAY_HOST, 0,
|
| - cls.WEBPAGEREPLAY_HTTP_PORT,
|
| - cls.WEBPAGEREPLAY_HTTPS_PORT,
|
| - replay_options)
|
| -
|
| -
|
| if __name__ == '__main__':
|
| pyauto_functional.Main()
|
|
|