| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
| 6 | 6 |
| 7 | 7 |
| 8 def _GetCurrentLocation(action_runner): | 8 def _GetCurrentLocation(action_runner): |
| 9 return action_runner.EvaluateJavaScript('document.location.href') | 9 return action_runner.EvaluateJavaScript('document.location.href') |
| 10 | 10 |
| 11 | 11 |
| 12 def _WaitForLocationChange(action_runner, old_href): | 12 def _WaitForLocationChange(action_runner, old_href): |
| 13 action_runner.WaitForJavaScriptCondition( | 13 action_runner.WaitForJavaScriptCondition( |
| 14 'document.location.href != "%s"' % old_href) | 14 'document.location.href != "%s"' % old_href) |
| 15 | 15 |
| 16 | 16 |
| 17 class GmailAltTwoLabelsPage(page_module.Page): | 17 class GmailAltTwoLabelsPage(page_module.Page): |
| 18 | 18 |
| 19 """ Why: Alternate between Inbox and Sent Mail """ | 19 """ Why: Alternate between Inbox and Sent Mail """ |
| 20 | 20 |
| 21 def __init__(self, page_set): | 21 def __init__(self, page_set): |
| 22 super(GmailAltTwoLabelsPage, self).__init__( | 22 super(GmailAltTwoLabelsPage, self).__init__( |
| 23 url='https://mail.google.com/mail/', | 23 url='https://mail.google.com/mail/', |
| 24 page_set=page_set, | 24 page_set=page_set, |
| 25 name='gmail_alt_two_labels') | 25 name='gmail_alt_two_labels', |
| 26 | 26 credentials_path = 'data/credentials.json') |
| 27 self.credentials_path = 'data/credentials.json' | |
| 28 self.credentials = 'google' | 27 self.credentials = 'google' |
| 29 self.user_agent_type = 'desktop' | 28 self.user_agent_type = 'desktop' |
| 30 self.archive_data_file = 'data/gmail_alt_two_labels.json' | 29 self.archive_data_file = 'data/gmail_alt_two_labels.json' |
| 31 | 30 |
| 32 def RunNavigateSteps(self, action_runner): | 31 def RunNavigateSteps(self, action_runner): |
| 33 action_runner.NavigateToPage(self) | 32 action_runner.NavigateToPage(self) |
| 34 action_runner.WaitForJavaScriptCondition( | 33 action_runner.WaitForJavaScriptCondition( |
| 35 'window.gmonkey !== undefined && ' | 34 'window.gmonkey !== undefined && ' |
| 36 'document.getElementById("gb") !== null') | 35 'document.getElementById("gb") !== null') |
| 37 | 36 |
| 38 def RunEndure(self, action_runner): | 37 def RunEndure(self, action_runner): |
| 39 old_href = _GetCurrentLocation(action_runner) | 38 old_href = _GetCurrentLocation(action_runner) |
| 40 action_runner.ClickElement( | 39 action_runner.ClickElement( |
| 41 'a[href="https://mail.google.com/mail/u/0/?shva=1#sent"]') | 40 'a[href="https://mail.google.com/mail/u/0/?shva=1#sent"]') |
| 42 _WaitForLocationChange(action_runner, old_href) | 41 _WaitForLocationChange(action_runner, old_href) |
| 43 action_runner.Wait(1) | 42 action_runner.Wait(1) |
| 44 old_href = _GetCurrentLocation(action_runner) | 43 old_href = _GetCurrentLocation(action_runner) |
| 45 action_runner.ClickElement( | 44 action_runner.ClickElement( |
| 46 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]') | 45 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]') |
| 47 _WaitForLocationChange(action_runner, old_href) | 46 _WaitForLocationChange(action_runner, old_href) |
| 48 action_runner.Wait(1) | 47 action_runner.Wait(1) |
| 49 | 48 |
| 50 | 49 |
| 51 class GmailAltTwoLabelsPageSet(page_set_module.PageSet): | 50 class GmailAltTwoLabelsPageSet(page_set_module.PageSet): |
| 52 | 51 |
| 53 """ Chrome Endure test for GMail. """ | 52 """ Chrome Endure test for GMail. """ |
| 54 | 53 |
| 55 def __init__(self): | 54 def __init__(self): |
| 56 super(GmailAltTwoLabelsPageSet, self).__init__( | 55 super(GmailAltTwoLabelsPageSet, self).__init__( |
| 57 credentials_path='data/credentials.json', | |
| 58 user_agent_type='desktop', | 56 user_agent_type='desktop', |
| 59 archive_data_file='data/gmail_alt_two_labels.json', | 57 archive_data_file='data/gmail_alt_two_labels.json', |
| 60 bucket=page_set_module.PUBLIC_BUCKET) | 58 bucket=page_set_module.PUBLIC_BUCKET) |
| 61 | 59 |
| 62 self.AddPage(GmailAltTwoLabelsPage(self)) | 60 self.AddPage(GmailAltTwoLabelsPage(self)) |
| OLD | NEW |