OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 import os | |
6 | |
7 from telemetry.page import page_set as page_set_module | |
8 | |
9 from page_sets import top_pages | |
10 from page_sets import top_7_stress | |
11 | |
12 def SpawnTab(action_runner): | |
Sami
2015/05/20 15:52:19
nit: Two blank lines between toplevel items please
ulan
2015/05/20 16:14:42
Done.
| |
13 return action_runner.EvaluateJavaScript("__telemetry_spawn_tab()") | |
Sami
2015/05/20 15:52:19
nit: single quotes for strings
ulan
2015/05/20 16:14:42
Done.
| |
14 | |
15 def CloseTab(action_runner, tab): | |
Sami
2015/05/20 15:52:19
_CloseTab
ulan
2015/05/20 16:14:42
Done.
| |
16 action_runner.EvaluateJavaScript("__telemetry_close_tab(" + str(tab) + ")") | |
Sami
2015/05/20 15:52:19
Ditto about quotes.
ulan
2015/05/20 16:14:42
Done.
| |
17 | |
18 def _CreateIdleMultiTabPageClass(base_page_cls, base_js): | |
19 class DerivedIdleMultiTabPage(base_page_cls): # pylint: disable=W0232 | |
20 | |
21 def RunPageInteractions(self, action_runner): | |
22 MAX_TABS = 10 | |
23 action_runner.ExecuteJavaScript(base_js) | |
24 tabs = {} | |
25 # Slowly open tabs. | |
26 for tab in xrange(MAX_TABS): | |
27 tabs[tab] = SpawnTab(action_runner) | |
28 action_runner.Wait(2) | |
29 action_runner.Wait(20) | |
30 # Slowly close tabs. | |
31 for tab in xrange(MAX_TABS): | |
32 CloseTab(action_runner, tabs[tab]) | |
33 action_runner.Wait(2) | |
34 action_runner.Wait(30) | |
35 # Quikly open tabs. | |
Sami
2015/05/20 15:52:20
typo: Quickly
ulan
2015/05/20 16:14:43
Done.
| |
36 for tab in xrange(MAX_TABS): | |
37 tabs[tab] = SpawnTab(action_runner) | |
38 action_runner.Wait(20) | |
39 # Quikly close tabs. | |
Sami
2015/05/20 15:52:20
Ditto.
ulan
2015/05/20 16:14:42
Done.
| |
40 for tab in xrange(MAX_TABS): | |
41 CloseTab(action_runner, tabs[tab]) | |
42 action_runner.Wait(30) | |
43 return DerivedIdleMultiTabPage | |
44 | |
45 | |
46 class IdleMultiTabCasesPageSet(page_set_module.PageSet): | |
47 | |
48 """ Pages for testing GC efficiency on idle pages. """ | |
49 | |
50 def __init__(self): | |
51 super(IdleMultiTabCasesPageSet, self).__init__( | |
52 user_agent_type='desktop', | |
53 archive_data_file='data/top_25.json', | |
54 bucket=page_set_module.PARTNER_BUCKET) | |
55 with open(os.path.join(os.path.dirname(__file__), | |
56 'idle_multi_tab_cases.js')) as f: | |
57 base_js = f.read() | |
58 pages = [ | |
59 top_pages.GoogleDocPage, | |
60 top_7_stress.GmailPage, | |
61 top_7_stress.GooglePlusPage, | |
62 ] | |
63 for page in pages: | |
64 self.AddUserStory(_CreateIdleMultiTabPageClass(page, base_js)(self)) | |
OLD | NEW |