Chromium Code Reviews| Index: tools/perf/page_sets/system_health/long_running_stories.py |
| diff --git a/tools/perf/page_sets/system_health/long_running_stories.py b/tools/perf/page_sets/system_health/long_running_stories.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1c4b288858ba12a491cb7d72419e206f9351c2f3 |
| --- /dev/null |
| +++ b/tools/perf/page_sets/system_health/long_running_stories.py |
| @@ -0,0 +1,93 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from page_sets.login_helpers import google_login |
| +from page_sets.system_health import platforms |
| +from page_sets.system_health import system_health_story |
| + |
| + |
| +IDLE_TIME_IN_SECONDS = 100 |
| +SAMPLING_INTERVAL_IN_SECONDS = 1 |
| +STEPS = IDLE_TIME_IN_SECONDS / SAMPLING_INTERVAL_IN_SECONDS |
| + |
| + |
| +class _LongRunningStory(system_health_story.SystemHealthStory): |
| + """Abstract base class for long running stories.""" |
| + IS_SINGLE_PAGE_APP = False |
| + ITEM_SELECTOR = NotImplemented |
|
petrcermak
2016/08/25 09:57:19
Remove these two constants (IS_SINGLE_PAGE_APP, IT
rnephew (Reviews Here)
2016/08/25 15:28:57
Done.
|
| + ABSTRACT_STORY = True |
| + BACKGROUND = False |
| + |
| + def RunPageInteractions(self, action_runner): |
| + super(_LongRunningStory, self).RunPageInteractions(action_runner) |
| + if self.BACKGROUND: |
| + action_runner.tab.browser.tabs.New() |
| + action_runner.tab.browser.DumpMemory() |
|
petrcermak
2016/08/25 09:57:19
instead of calling DumpMemory directly, please do
rnephew (Reviews Here)
2016/08/25 15:28:57
Done.
|
| + for _ in xrange(STEPS): |
| + action_runner.Wait(SAMPLING_INTERVAL_IN_SECONDS) |
| + action_runner.tab.browser.DumpMemory() |
| + |
| + |
| +############################################################################## |
| +# Long running gmail stories. |
|
petrcermak
2016/08/25 09:57:19
nit: s/gmail/Gmail/
rnephew (Reviews Here)
2016/08/25 15:28:57
Done.
|
| +############################################################################## |
| + |
| + |
| +class _LongRunningGmailBase(_LongRunningStory): |
|
petrcermak
2016/08/25 09:57:19
There's a lot of code duplication between this fil
rnephew (Reviews Here)
2016/08/25 15:28:57
Added todo, will start working on merging them nex
|
| + URL = 'https://mail.google.com/mail/' |
| + ABSTRACT_STORY = True |
| + |
| + def _Login(self, action_runner): |
| + google_login.LoginGoogleAccount(action_runner, 'googletest', |
| + self.credentials_path) |
| + |
| + # Navigating to https://mail.google.com immediately leads to an infinite |
| + # redirection loop due to a bug in WPR (see |
| + # https://github.com/chromium/web-page-replay/issues/70). We therefore first |
| + # navigate to a sub-URL to set up the session and hit the resulting |
| + # redirection loop. Afterwards, we can safely navigate to |
| + # https://mail.google.com. |
| + action_runner.Navigate( |
| + 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop') |
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| + |
| +class _LongRunningGmailMobileBase(_LongRunningGmailBase): |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + # Close the "Get Inbox by Gmail" interstitial. |
| + action_runner.WaitForJavaScriptCondition( |
| + 'document.querySelector("#isppromo a") !== null') |
| + action_runner.ExecuteJavaScript( |
| + 'document.querySelector("#isppromo a").click()') |
| + # Wait until the UI loads. |
| + action_runner.WaitForJavaScriptCondition( |
| + 'document.getElementById("apploadingdiv").style.height === "0px"') |
| + |
| + |
| +class _LongRunningGmailDesktopBase(_LongRunningGmailBase): |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + # Wait until the UI loads. |
| + action_runner.WaitForJavaScriptCondition( |
| + 'document.getElementById("loading").style.display === "none"') |
| + |
| + |
| +class LongRunningGmailMobileForegroundStory(_LongRunningGmailMobileBase): |
| + NAME = 'long_running:tools:gmail-foreground' |
| + |
| + |
| +class LongRunningGmailDesktopForegroundStory(_LongRunningGmailDesktopBase): |
| + NAME = 'long_running:tools:gmail-foreground' |
| + |
| + |
| +class LongRunningGmailMobileBackgroundStory(_LongRunningGmailMobileBase): |
| + BACKGROUND = True |
| + NAME = 'long_running:tools:gmail-background' |
| + |
| + |
| +class LongRunningGmailDesktopBackgroundStory(_LongRunningGmailDesktopBase): |
| + BACKGROUND = True |
| + NAME = 'long_running:tools:gmail-background' |