[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / perf / page_sets / idle_multi_tab_cases.py
bloba6b6e2e9b2efc82c93fa5b22b6af7d6d6c9e9289
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 import os
7 from telemetry.page import shared_page_state
8 from telemetry import story
10 from page_sets import top_7_stress
11 from page_sets import top_pages
14 def _SpawnTab(action_runner):
15 return action_runner.EvaluateJavaScript('__telemetry_spawn_tab()')
18 def _CloseTab(action_runner, tab):
19 action_runner.EvaluateJavaScript('__telemetry_close_tab(' + str(tab) + ')')
22 def _CreateIdleMultiTabPageClass(base_page_cls, base_js):
23 class DerivedIdleMultiTabPage(base_page_cls): # pylint: disable=W0232
25 def RunPageInteractions(self, action_runner):
26 MAX_TABS = 10
27 action_runner.ExecuteJavaScript(base_js)
28 tabs = {}
29 # Slowly open tabs.
30 for tab in xrange(MAX_TABS):
31 tabs[tab] = _SpawnTab(action_runner)
32 action_runner.Wait(1)
33 action_runner.Wait(20)
34 # Slowly close tabs.
35 for tab in xrange(MAX_TABS):
36 _CloseTab(action_runner, tabs[tab])
37 action_runner.Wait(1)
38 action_runner.Wait(30)
39 # Quickly open tabs.
40 for tab in xrange(MAX_TABS):
41 tabs[tab] = _SpawnTab(action_runner)
42 action_runner.Wait(20)
43 # Quickly close tabs.
44 for tab in xrange(MAX_TABS):
45 _CloseTab(action_runner, tabs[tab])
46 action_runner.Wait(30)
47 return DerivedIdleMultiTabPage
50 class IdleMultiTabCasesPageSet(story.StorySet):
52 """ Pages for testing GC efficiency on idle pages. """
54 def __init__(self):
55 super(IdleMultiTabCasesPageSet, self).__init__(
56 archive_data_file='data/top_25.json',
57 cloud_storage_bucket=story.PARTNER_BUCKET)
58 with open(os.path.join(os.path.dirname(__file__),
59 'idle_multi_tab_cases.js')) as f:
60 base_js = f.read()
61 self.AddStory(
62 _CreateIdleMultiTabPageClass(top_pages.GoogleDocPage, base_js)
63 (self, shared_page_state.SharedDesktopPageState))
64 self.AddStory(
65 _CreateIdleMultiTabPageClass(top_7_stress.GooglePlusPage, base_js)
66 (self))