| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from page_sets.login_helpers import google_login |
| 6 from page_sets.system_health import platforms |
| 7 from page_sets.system_health import system_health_story |
| 8 |
| 9 from telemetry import decorators |
| 10 |
| 11 |
| 12 IDLE_TIME_IN_SECONDS = 100 |
| 13 SAMPLING_INTERVAL_IN_SECONDS = 1 |
| 14 STEPS = IDLE_TIME_IN_SECONDS / SAMPLING_INTERVAL_IN_SECONDS |
| 15 |
| 16 |
| 17 class _LongRunningStory(system_health_story.SystemHealthStory): |
| 18 """Abstract base class for long running stories.""" |
| 19 ABSTRACT_STORY = True |
| 20 BACKGROUND = False |
| 21 |
| 22 def RunPageInteractions(self, action_runner): |
| 23 super(_LongRunningStory, self).RunPageInteractions(action_runner) |
| 24 if self.BACKGROUND: |
| 25 action_runner.tab.browser.tabs.New() |
| 26 if self._take_memory_measurement: |
| 27 action_runner.MeasureMemory() |
| 28 for _ in xrange(STEPS): |
| 29 action_runner.Wait(SAMPLING_INTERVAL_IN_SECONDS) |
| 30 if self._take_memory_measurement: |
| 31 action_runner.MeasureMemory() |
| 32 |
| 33 |
| 34 ############################################################################## |
| 35 # Long running Gmail stories. |
| 36 ############################################################################## |
| 37 |
| 38 # TODO(rnephew): Merge _Login() and _DidLoadDocument() with methods in |
| 39 # loading_stories. |
| 40 class _LongRunningGmailBase(_LongRunningStory): |
| 41 URL = 'https://mail.google.com/mail/' |
| 42 ABSTRACT_STORY = True |
| 43 |
| 44 def _Login(self, action_runner): |
| 45 google_login.LoginGoogleAccount(action_runner, 'googletest', |
| 46 self.credentials_path) |
| 47 |
| 48 # Navigating to https://mail.google.com immediately leads to an infinite |
| 49 # redirection loop due to a bug in WPR (see |
| 50 # https://github.com/chromium/web-page-replay/issues/70). We therefore first |
| 51 # navigate to a sub-URL to set up the session and hit the resulting |
| 52 # redirection loop. Afterwards, we can safely navigate to |
| 53 # https://mail.google.com. |
| 54 action_runner.Navigate( |
| 55 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop') |
| 56 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 57 |
| 58 class _LongRunningGmailMobileBase(_LongRunningGmailBase): |
| 59 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 60 |
| 61 def _DidLoadDocument(self, action_runner): |
| 62 # Close the "Get Inbox by Gmail" interstitial. |
| 63 action_runner.WaitForJavaScriptCondition( |
| 64 'document.querySelector("#isppromo a") !== null') |
| 65 action_runner.ExecuteJavaScript( |
| 66 'document.querySelector("#isppromo a").click()') |
| 67 # Wait until the UI loads. |
| 68 action_runner.WaitForJavaScriptCondition( |
| 69 'document.getElementById("apploadingdiv").style.height === "0px"') |
| 70 |
| 71 |
| 72 class _LongRunningGmailDesktopBase(_LongRunningGmailBase): |
| 73 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 74 |
| 75 def _DidLoadDocument(self, action_runner): |
| 76 # Wait until the UI loads. |
| 77 action_runner.WaitForJavaScriptCondition( |
| 78 'document.getElementById("loading").style.display === "none"') |
| 79 |
| 80 |
| 81 class LongRunningGmailMobileForegroundStory(_LongRunningGmailMobileBase): |
| 82 NAME = 'long_running:tools:gmail-foreground' |
| 83 |
| 84 |
| 85 class LongRunningGmailDesktopForegroundStory(_LongRunningGmailDesktopBase): |
| 86 NAME = 'long_running:tools:gmail-foreground' |
| 87 |
| 88 |
| 89 # crbug.com/643110 |
| 90 @decorators.Disabled('android') |
| 91 class LongRunningGmailMobileBackgroundStory(_LongRunningGmailMobileBase): |
| 92 BACKGROUND = True |
| 93 NAME = 'long_running:tools:gmail-background' |
| 94 |
| 95 |
| 96 class LongRunningGmailDesktopBackgroundStory(_LongRunningGmailDesktopBase): |
| 97 BACKGROUND = True |
| 98 NAME = 'long_running:tools:gmail-background' |
| OLD | NEW |