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