Index: tools/perf/page_sets/system_health/single_page_stories.py |
diff --git a/tools/perf/page_sets/system_health/single_page_stories.py b/tools/perf/page_sets/system_health/single_page_stories.py |
index efd8e09f518ee37179a8bda1a48e65cefaa26db3..e8e3daa404d0b2db8d757167da999a7c35f930dc 100644 |
--- a/tools/perf/page_sets/system_health/single_page_stories.py |
+++ b/tools/perf/page_sets/system_health/single_page_stories.py |
@@ -2,81 +2,23 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-import logging |
import sys |
+from page_sets.system_health import platforms |
+from page_sets.system_health import system_health_story |
+ |
from page_sets.login_helpers import dropbox_login |
from page_sets.login_helpers import google_login |
-from telemetry.core import discover |
-from telemetry.page import page |
- |
- |
-_ALL_PLATFORMS = frozenset({'desktop', 'mobile'}) |
-_DESKTOP_ONLY = frozenset({'desktop'}) |
-_MOBILE_ONLY = frozenset({'mobile'}) |
-_NO_PLATFORMS = frozenset() |
- |
- |
-_DUMP_WAIT_TIME = 3 |
- |
-class _SinglePageStory(page.Page): |
+class _SinglePageStory(system_health_story.SystemHealthStory): |
"""Abstract base class for single-page System Health user stories.""" |
- |
- # The full name of a single page story has the form CASE:GROUP:PAGE (e.g. |
- # 'load:search:google'). |
- NAME = NotImplemented |
- URL = NotImplemented |
- SUPPORTED_PLATFORMS = _ALL_PLATFORMS |
- |
- def __init__(self, story_set, take_memory_measurement): |
- case, group, _ = self.NAME.split(':') |
- super(_SinglePageStory, self).__init__( |
- page_set=story_set, name=self.NAME, url=self.URL, |
- credentials_path='../data/credentials.json', |
- grouping_keys={'case': case, 'group': group}) |
- self._take_memory_measurement = take_memory_measurement |
- |
- def _Measure(self, action_runner): |
- if not self._take_memory_measurement: |
- return |
- # TODO(petrcermak): This method is essentially the same as |
- # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py. |
- # Consider sharing the common code. |
- action_runner.Wait(_DUMP_WAIT_TIME) |
- action_runner.ForceGarbageCollection() |
- action_runner.Wait(_DUMP_WAIT_TIME) |
- tracing_controller = action_runner.tab.browser.platform.tracing_controller |
- if not tracing_controller.is_tracing_running: |
- return # Tracing is not running, e.g., when recording a WPR archive. |
- if not action_runner.tab.browser.DumpMemory(): |
- logging.error('Unable to get a memory dump for %s.', self.name) |
- |
- def _Login(self, action_runner): |
- pass |
- |
- def _DidLoadDocument(self, action_runner): |
- pass |
- |
- def RunNavigateSteps(self, action_runner): |
- self._Login(action_runner) |
- super(_SinglePageStory, self).RunNavigateSteps(action_runner) |
- |
- def RunPageInteractions(self, action_runner): |
- action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
- self._DidLoadDocument(action_runner) |
- self._Measure(action_runner) |
+ pass |
def IterAllStoryClasses(): |
- # Sort the classes by their names so that their order is stable and |
- # deterministic. |
- for unused_cls_name, cls in sorted(discover.DiscoverClassesInModule( |
- module=sys.modules[__name__], |
- base_class=_SinglePageStory, |
- index_by_class_name=True).iteritems()): |
- yield cls |
+ return system_health_story.IterAllStoryClasses( |
+ sys.modules[__name__], _SinglePageStory) |
################################################################################ |
@@ -107,14 +49,14 @@ class LoadAmazonStory(_SinglePageStory): |
class LoadTaobaoDesktopStory(_SinglePageStory): |
NAME = 'load:search:taobao' |
URL = 'https://world.taobao.com/' |
- SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
class LoadTaobaoMobileStory(_SinglePageStory): |
NAME = 'load:search:taobao' |
# "ali_trackid" in the URL suppresses "Download app" interstitial. |
URL = 'http://m.intl.taobao.com/?ali_trackid' |
- SUPPORTED_PLATFORMS = _MOBILE_ONLY |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
class LoadYandexStory(_SinglePageStory): |
@@ -151,7 +93,7 @@ class LoadVkStory(_SinglePageStory): |
# set by https://vk.com immediately expires, so the page keeps refreshing |
# indefinitely on mobile |
# (see https://github.com/chromium/web-page-replay/issues/71). |
- SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
class LoadInstagramStory(_SinglePageStory): |
@@ -184,28 +126,42 @@ class LoadBbcStory(_SinglePageStory): |
class LoadCnnStory(_SinglePageStory): |
NAME = 'load:news:cnn' |
# Using "https://" shows "Your connection is not private". |
- URL = ( |
- 'http://edition.cnn.com/2016/05/02/health/three-habitable-planets-earth-dwarf-star/index.html') |
+ URL = 'http://edition.cnn.com' |
-class LoadRedditDesktopStory(_SinglePageStory): |
- NAME = 'load:news:reddit' |
- URL = ( |
- 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_horror_story/') |
- SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
+class LoadHackerNewsStory(_SinglePageStory): |
+ NAME = 'load:news:hackernews' |
+ URL = 'https://news.ycombinator.com' |
-class LoadRedditMobileStory(_SinglePageStory): |
- NAME = 'load:news:reddit' |
- URL = ( |
- 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_horror_story/') |
- SUPPORTED_PLATFORMS = _MOBILE_ONLY |
+class LoadNytimesDesktopStory(_SinglePageStory): |
+ NAME = 'load:news:nytimes' |
+ URL = 'http://www.nytimes.com' |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
+ |
+ |
+class LoadNytimesMobileStory(_SinglePageStory): |
+ NAME = 'load:news:nytimes' |
+ URL = 'http://mobile.nytimes.com' |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
class LoadQqMobileStory(_SinglePageStory): |
NAME = 'load:news:qq' |
# Using "https://" hangs and shows "This site can't be reached". |
- URL = 'http://news.qq.com/a/20160503/003186.htm' |
+ URL = 'http://news.qq.com' |
+ |
+ |
+class LoadRedditDesktopStory(_SinglePageStory): |
+ NAME = 'load:news:reddit' |
+ URL = 'https://www.reddit.com/top/?sort=top&t=week' |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
+ |
+ |
+class LoadRedditMobileStory(_SinglePageStory): |
+ NAME = 'load:news:reddit' |
+ URL = 'https://m.reddit.com/?sort=top&time=week' |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
class LoadSohuStory(_SinglePageStory): |
@@ -216,7 +172,17 @@ class LoadSohuStory(_SinglePageStory): |
# The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost |
# always fails to completely load due to |
# https://github.com/chromium/web-page-replay/issues/74. |
- SUPPORTED_PLATFORMS = _MOBILE_ONLY |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
+ |
+ |
+class LoadWashingtonPostMobileStory(_SinglePageStory): |
+ NAME = 'load:news:washingtonpost' |
+ URL = 'https://www.washingtonpost.com/pwa' |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
+ |
+ def _DidLoadDocument(self, action_runner): |
+ # Close the popup window. |
+ action_runner.ClickElement(selector='.close') |
class LoadWikipediaStory(_SinglePageStory): |
@@ -286,7 +252,7 @@ class LoadDocsStory(_SinglePageStory): |
class _LoadGmailBaseStory(_SinglePageStory): |
NAME = 'load:tools:gmail' |
URL = 'https://mail.google.com/mail/' |
- SUPPORTED_PLATFORMS = _NO_PLATFORMS |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
def _Login(self, action_runner): |
google_login.LoginGoogleAccount(action_runner, 'googletest', |
@@ -304,7 +270,7 @@ class _LoadGmailBaseStory(_SinglePageStory): |
class LoadGmailDesktopStory(_LoadGmailBaseStory): |
- SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
def _DidLoadDocument(self, action_runner): |
# Wait until the UI loads. |
@@ -312,7 +278,7 @@ class LoadGmailDesktopStory(_LoadGmailBaseStory): |
'document.getElementById("loading").style.display === "none"') |
class LoadGmailMobileStory(_LoadGmailBaseStory): |
- SUPPORTED_PLATFORMS = _MOBILE_ONLY |
+ SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
def _DidLoadDocument(self, action_runner): |
# Close the "Get Inbox by Gmail" interstitial. |
@@ -397,11 +363,11 @@ class LoadMiniclipStory(_SinglePageStory): |
# Using "https://" causes "404 Not Found" during WPR recording. |
URL = 'http://www.miniclip.com/games/en/' |
# Desktop only (requires Flash). |
- SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
class LoadAlphabettyStory(_SinglePageStory): |
NAME = 'load:games:alphabetty' |
URL = 'https://king.com/play/alphabetty' |
# Desktop only (requires Flash). |
- SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |