1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# 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.
from telemetry.page import shared_page_state
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
_SCROLL_LIST_ITEM = ('.scroll-list-item .%s')
_NUM_REPEATS_FOR_EMAIL_OPEN = 40
_OPEN_CLOSE_WAIT_TIME = 0.3
class InboxPage(page_module.Page):
"""A class defining inbox page for telemetry."""
def __init__(self, page_set):
super(InboxPage, self).__init__(
url=('http://localhost/?mark_read_on_open=false&'
'jsmode=du&preload_anim=True&welcome=0'),
page_set=page_set,
shared_page_state_class=shared_page_state.SharedDesktopPageState,
credentials_path='data/inbox_credentials.json',
name='Inbox')
self.credentials = 'google'
def RunNavigateSteps(self, action_runner):
action_runner.Navigate(self.url, timeout_in_seconds=180)
def RunPageInteractions(self, action_runner):
self.OpenCloseConv(action_runner)
def _WaitForItemOpen(self, action_runner):
action_runner.WaitForJavaScriptCondition(
'BT_AutoTestHelper.getInstance().getOpenItemId() && '
'BT_AutoTestHelper.getInstance().'
'getOpenItemLoadedRenderComplete() && '
'BT_AutoTestHelper.getInstance().getOutstandingRenderCount() '
'== 0')
def _WaitForItemClose(self, action_runner):
action_runner.WaitForJavaScriptCondition(
'!BT_AutoTestHelper.getInstance().getOpenItemId() && '
'BT_AutoTestHelper.getInstance().getOutstandingRenderCount() '
'== 0')
def _ClickToOpenItem(self, action_runner):
action_runner.MouseClick(_SCROLL_LIST_ITEM % 'summItemSection_')
def _ClickToCloseItem(self, action_runner):
action_runner.MouseClick(_SCROLL_LIST_ITEM % 'fullItemHeader_')
def _WaitForInitialSync(self, action_runner):
# This wait is to make sure that the actual background sync starts
# properly and we are not capturing the initial default synced status.
action_runner.Wait(120)
action_runner.WaitForJavaScriptCondition(
'window.BT_events && '
'BT_events.ITEMS_LOADED && BT_events.INITIAL_SYNC_COMPLETE', 90)
def _OpenAndCloseEmail(self, action_runner):
self._ClickToOpenItem(action_runner)
self._WaitForItemOpen(action_runner)
action_runner.Wait(_OPEN_CLOSE_WAIT_TIME)
self._ClickToCloseItem(action_runner)
self._WaitForItemClose(action_runner)
action_runner.Wait(_OPEN_CLOSE_WAIT_TIME)
def OpenCloseConv(self, action_runner):
# Wait for the page to load and start background sync
self._WaitForInitialSync(action_runner)
for _ in range(0, _NUM_REPEATS_FOR_EMAIL_OPEN):
self._OpenAndCloseEmail(action_runner)
action_runner.Wait(10)
class InboxPageSet(page_set_module.PageSet):
"""Inbox page set."""
def __init__(self):
super(InboxPageSet, self).__init__(
archive_data_file='data/inbox_data.json',
bucket=page_set_module.INTERNAL_BUCKET
)
self.AddUserStory(InboxPage(self))
|