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