blob: e324cfbf3069dbcd2a4caec80d106880280196d6 [file] [log] [blame]
# Copyright 2015 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.
import re
from import page as page_module
from import shared_page_state
from telemetry import story as story_module
from import keyevent # pylint: disable=import-error
from page_sets import top_10_mobile
class Top10MobileSharedState(shared_page_state.SharedMobilePageState):
def ShouldStopBrowserAfterStoryRun(self, story):
# Close the browser after each background story.
return isinstance(story, BackgroundPage)
class MemoryMeasurementPage(page_module.Page):
"""Abstract class for measuring memory on a story unit."""
_PHASE = NotImplemented
def __init__(self, story_set, name, url):
super(MemoryMeasurementPage, self).__init__(
page_set=story_set, name=name, url=url,
grouping_keys={'phase': self._PHASE})
class ForegroundPage(MemoryMeasurementPage):
"""Take a measurement after loading a regular webpage."""
_PHASE = 'foreground'
def __init__(self, story_set, name, url):
super(ForegroundPage, self).__init__(story_set, name, url)
def RunPageInteractions(self, action_runner):
class BackgroundPage(MemoryMeasurementPage):
"""Take a measurement while Chrome is in the background."""
_PHASE = 'background'
def __init__(self, story_set, name):
super(BackgroundPage, self).__init__(story_set, name, 'about:blank')
def RunNavigateSteps(self, action_runner):
# Launch clock app, pushing Chrome to the background.
android_browser =
def RunPageInteractions(self, action_runner):
# Take measurement.
# Go back to Chrome.
android_browser =
class MemoryTop10Mobile(story_module.StorySet):
"""User story to measure foreground/background memory in top 10 mobile."""
def __init__(self):
super(MemoryTop10Mobile, self).__init__(
for url in top_10_mobile.URL_LIST:
# We name pages so their foreground/background counterparts are easy
# to identify. For example '' becomes
# 'http_google_com' and 'after_http_google_com' respectively.
# This also allows to use e.g. '--story-filter http_google_com' to
# match and run both parts of the story.
name = re.sub(r'\W+', '_', url)
self.AddStory(ForegroundPage(self, name, url))
self.AddStory(BackgroundPage(self, 'after_' + name))