[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / perf / page_sets / memory_health_story.py
blob51394065a9e712ab1b310c3310b4870149a66cae
1 # Copyright 2015 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.
5 from telemetry.core import util
6 from telemetry.page import page as page_module
7 from telemetry.page import shared_page_state
8 from telemetry import story
10 util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android')
11 from pylib.constants import keyevent # pylint: disable=import-error
12 from pylib.device import intent # pylint: disable=import-error
15 URL_LIST = [
16 'http://google.com',
17 'http://vimeo.com',
18 'http://yahoo.com',
19 'http://baidu.com',
20 'http://cnn.com',
21 'http://yandex.ru',
22 'http://yahoo.co.jp',
23 'http://amazon.com',
24 'http://ebay.com',
25 'http://bing.com',
29 class ForegroundPage(page_module.Page):
30 """Take a measurement after loading a regular webpage."""
32 def __init__(self, story_set, url):
33 super(ForegroundPage, self).__init__(
34 url=url, page_set=story_set, name=url,
35 shared_page_state_class=shared_page_state.SharedMobilePageState)
36 self.archive_data_file = story_set.archive_data_file
38 def RunPageInteractions(self, action_runner):
39 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
40 with action_runner.CreateInteraction('foreground'):
41 # TODO(perezju): This should catch a few memory dumps. When available,
42 # use the dump API to request dumps on demand crbug.com/505826
43 action_runner.Wait(7)
46 class BackgroundPage(page_module.Page):
47 """Take a measurement while Chrome is in the background."""
49 def __init__(self, story_set, number):
50 super(BackgroundPage, self).__init__(
51 url='about:blank', page_set=story_set,
52 name='chrome_background_%d' % number,
53 shared_page_state_class=shared_page_state.SharedMobilePageState)
54 self.archive_data_file = story_set.archive_data_file
56 def RunPageInteractions(self, action_runner):
57 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
59 # launch clock app, pushing Chrome to the background
60 android_platform = action_runner.tab.browser.platform
61 android_platform.LaunchAndroidApplication(
62 intent.Intent(package='com.google.android.deskclock',
63 activity='com.android.deskclock.DeskClock'),
64 app_has_webviews=False)
66 # take measurement
67 with action_runner.CreateInteraction('background'):
68 # TODO(perezju): This should catch a few memory dumps. When available,
69 # use the dump API to request dumps on demand crbug.com/505826
70 action_runner.Wait(7)
72 # go back to Chrome
73 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
76 class MemoryHealthStory(story.StorySet):
77 """User story for the Memory Health Plan."""
79 def __init__(self):
80 super(MemoryHealthStory, self).__init__(
81 archive_data_file='data/memory_health_plan.json',
82 cloud_storage_bucket=story.PARTNER_BUCKET)
84 for number, url in enumerate(URL_LIST, 1):
85 self.AddStory(ForegroundPage(self, url))
86 self.AddStory(BackgroundPage(self, number))