| OLD | NEW |
| (Empty) |
| 1 # Copyright 2014 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 re | |
| 6 | |
| 7 from telemetry.page import page as page_module | |
| 8 from telemetry.page import page_set as page_set_module | |
| 9 | |
| 10 | |
| 11 def _CreateXpathFunction(xpath): | |
| 12 return ('document.evaluate("%s",' | |
| 13 'document,' | |
| 14 'null,' | |
| 15 'XPathResult.FIRST_ORDERED_NODE_TYPE,' | |
| 16 'null)' | |
| 17 '.singleNodeValue' % re.escape(xpath)) | |
| 18 | |
| 19 | |
| 20 def _GetCurrentLocation(action_runner): | |
| 21 return action_runner.EvaluateJavaScript('document.location.href') | |
| 22 | |
| 23 | |
| 24 def _WaitForLocationChange(action_runner, old_href): | |
| 25 action_runner.WaitForJavaScriptCondition( | |
| 26 'document.location.href != "%s"' % old_href) | |
| 27 | |
| 28 | |
| 29 class GmailAltThreadlistConversationPage( | |
| 30 page_module.Page): | |
| 31 | |
| 32 """ Why: Alternate between Inbox and the first email conversation. """ | |
| 33 | |
| 34 def __init__(self, page_set): | |
| 35 super(GmailAltThreadlistConversationPage, self).__init__( | |
| 36 url='https://mail.google.com/mail/', | |
| 37 page_set=page_set, | |
| 38 name='gmail_alt_threadlist_conversation', | |
| 39 credentials_path = 'data/credentials.json') | |
| 40 self.user_agent_type = 'desktop' | |
| 41 self.archive_data_file = 'data/gmail_alt_threadlist_conversation.json' | |
| 42 self.credentials = 'google' | |
| 43 | |
| 44 def RunNavigateSteps(self, action_runner): | |
| 45 action_runner.NavigateToPage(self) | |
| 46 action_runner.WaitForJavaScriptCondition( | |
| 47 'window.gmonkey !== undefined && ' | |
| 48 'document.getElementById("gb") !== null') | |
| 49 | |
| 50 def RunEndure(self, action_runner): | |
| 51 old_href = _GetCurrentLocation(action_runner) | |
| 52 action_runner.ClickElement( | |
| 53 element_function=_CreateXpathFunction('//span[@email]')) | |
| 54 _WaitForLocationChange(action_runner, old_href) | |
| 55 action_runner.Wait(1) | |
| 56 old_href = _GetCurrentLocation(action_runner) | |
| 57 action_runner.ClickElement( | |
| 58 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]') | |
| 59 _WaitForLocationChange(action_runner, old_href) | |
| 60 action_runner.Wait(1) | |
| 61 | |
| 62 | |
| 63 class GmailAltThreadlistConversationPageSet(page_set_module.PageSet): | |
| 64 | |
| 65 """ Chrome Endure test for GMail. """ | |
| 66 | |
| 67 def __init__(self): | |
| 68 super(GmailAltThreadlistConversationPageSet, self).__init__( | |
| 69 user_agent_type='desktop', | |
| 70 archive_data_file='data/gmail_alt_threadlist_conversation.json', | |
| 71 bucket=page_set_module.PUBLIC_BUCKET) | |
| 72 | |
| 73 self.AddPage(GmailAltThreadlistConversationPage(self)) | |
| OLD | NEW |