Home | History | Annotate | Download | only in page_sets
      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 # pylint: disable=W0401,W0614
      5 from telemetry.page.actions.all_page_actions import *
      6 from telemetry.page import page as page_module
      7 from telemetry.page import page_set as page_set_module
      8 
      9 
     10 def _GetCurrentLocation(action_runner):
     11   return action_runner.EvaluateJavaScript('document.location.href')
     12 
     13 
     14 def _WaitForLocationChange(action_runner, old_href):
     15   action_runner.WaitForJavaScriptCondition(
     16       'document.location.href != "%s"' % old_href)
     17 
     18 
     19 class GmailAltTwoLabelsPage(page_module.Page):
     20 
     21   """ Why: Alternate between Inbox and Sent Mail """
     22 
     23   def __init__(self, page_set):
     24     super(GmailAltTwoLabelsPage, self).__init__(
     25       url='https://mail.google.com/mail/',
     26       page_set=page_set,
     27       name='gmail_alt_two_labels')
     28 
     29     self.credentials_path = 'data/credentials.json'
     30     self.credentials = 'google'
     31     self.user_agent_type = 'desktop'
     32     self.archive_data_file = 'data/gmail_alt_two_labels.json'
     33 
     34   def RunNavigateSteps(self, action_runner):
     35     action_runner.NavigateToPage(self)
     36     action_runner.WaitForJavaScriptCondition(
     37         'window.gmonkey !== undefined && '
     38         'document.getElementById("gb") !== null')
     39 
     40   def RunEndure(self, action_runner):
     41     old_href = _GetCurrentLocation(action_runner)
     42     action_runner.ClickElement(
     43         'a[href="https://mail.google.com/mail/u/0/?shva=1#sent"]')
     44     _WaitForLocationChange(action_runner, old_href)
     45     action_runner.Wait(1)
     46     old_href = _GetCurrentLocation(action_runner)
     47     action_runner.ClickElement(
     48         'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]')
     49     _WaitForLocationChange(action_runner, old_href)
     50     action_runner.Wait(1)
     51 
     52 
     53 class GmailAltTwoLabelsPageSet(page_set_module.PageSet):
     54 
     55   """ Chrome Endure test for GMail. """
     56 
     57   def __init__(self):
     58     super(GmailAltTwoLabelsPageSet, self).__init__(
     59       credentials_path='data/credentials.json',
     60       user_agent_type='desktop',
     61       archive_data_file='data/gmail_alt_two_labels.json',
     62       bucket=page_set_module.PUBLIC_BUCKET)
     63 
     64     self.AddPage(GmailAltTwoLabelsPage(self))
     65