[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / page_sets / inbox.py
blobdbf8b1815590d2d1a4d2ab1c3b6c140c1142f6d0
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.page import page as page_module
6 from telemetry.page import page_set as page_set_module
8 _SCROLL_LIST_ITEM = ('.scroll-list-item .%s')
9 _NUM_REPEATS_FOR_EMAIL_OPEN = 40
10 _OPEN_CLOSE_WAIT_TIME = 0.3
13 class InboxPage(page_module.Page):
14 """A class defining inbox page for telemetry."""
16 def __init__(self, page_set):
17 super(InboxPage, self).__init__(
18 url=('http://localhost/?mark_read_on_open=false&'
19 'jsmode=du&preload_anim=True&welcome=0'),
20 page_set=page_set,
21 credentials_path='data/inbox_credentials.json',
22 name='Inbox')
23 self.user_agent_type = 'desktop'
24 self.credentials = 'google'
26 def RunNavigateSteps(self, action_runner):
27 action_runner.NavigateToPage(self, 180)
29 def RunPageInteractions(self, action_runner):
30 self.OpenCloseConv(action_runner)
32 def _WaitForItemOpen(self, action_runner):
33 action_runner.WaitForJavaScriptCondition(
34 'BT_AutoTestHelper.getInstance().getOpenItemId() && '
35 'BT_AutoTestHelper.getInstance().'
36 'getOpenItemLoadedRenderComplete() && '
37 'BT_AutoTestHelper.getInstance().getOutstandingRenderCount() '
38 '== 0')
40 def _WaitForItemClose(self, action_runner):
41 action_runner.WaitForJavaScriptCondition(
42 '!BT_AutoTestHelper.getInstance().getOpenItemId() && '
43 'BT_AutoTestHelper.getInstance().getOutstandingRenderCount() '
44 '== 0')
46 def _ClickToOpenItem(self, action_runner):
47 action_runner.MouseClick(_SCROLL_LIST_ITEM % 'summItemSection_')
49 def _ClickToCloseItem(self, action_runner):
50 action_runner.MouseClick(_SCROLL_LIST_ITEM % 'fullItemHeader_')
52 def _WaitForInitialSync(self, action_runner):
53 # This wait is to make sure that the actual background sync starts
54 # properly and we are not capturing the initial default synced status.
55 action_runner.Wait(120)
56 action_runner.WaitForJavaScriptCondition(
57 'window.BT_events && '
58 'BT_events.ITEMS_LOADED && BT_events.INITIAL_SYNC_COMPLETE', 90)
60 def _OpenAndCloseEmail(self, action_runner):
61 self._ClickToOpenItem(action_runner)
62 self._WaitForItemOpen(action_runner)
63 action_runner.Wait(_OPEN_CLOSE_WAIT_TIME)
64 self._ClickToCloseItem(action_runner)
65 self._WaitForItemClose(action_runner)
66 action_runner.Wait(_OPEN_CLOSE_WAIT_TIME)
68 def OpenCloseConv(self, action_runner):
69 # Wait for the page to load and start background sync
70 self._WaitForInitialSync(action_runner)
71 for _ in range(0, _NUM_REPEATS_FOR_EMAIL_OPEN):
72 self._OpenAndCloseEmail(action_runner)
73 action_runner.Wait(10)
76 class InboxPageSet(page_set_module.PageSet):
78 """Inbox page set."""
80 def __init__(self):
81 super(InboxPageSet, self).__init__(
82 user_agent_type='desktop',
83 archive_data_file='data/inbox_data.json',
84 bucket=page_set_module.INTERNAL_BUCKET
87 self.AddUserStory(InboxPage(self))