Commit 685c0a02 authored by chrishenry@google.com's avatar chrishenry@google.com

Kill wait_until support, which is unused once ClickElementAction is

converted to use the new ActionRunner API.

BUG=361809

Review URL: https://codereview.chromium.org/321253004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276786 0039d316-1c4b-4281-b951-d872f2087c98
parent 36df0635
...@@ -18,9 +18,8 @@ class ActionRunner(object): ...@@ -18,9 +18,8 @@ class ActionRunner(object):
# TODO(nednguyen): remove this (or make private) when # TODO(nednguyen): remove this (or make private) when
# crbug.com/361809 is marked fixed # crbug.com/361809 is marked fixed
def RunAction(self, action): def RunAction(self, action):
if not action.WillWaitAfterRun(): action.WillRunAction(self._tab)
action.WillRunAction(self._tab) action.RunAction(self._tab)
action.RunActionAndMaybeWait(self._tab)
def BeginInteraction(self, label, is_smooth=False, is_responsive=False): def BeginInteraction(self, label, is_smooth=False, is_responsive=False):
"""Marks the beginning of an interaction record. """Marks the beginning of an interaction record.
......
...@@ -18,9 +18,6 @@ class GestureAction(page_action.PageAction): ...@@ -18,9 +18,6 @@ class GestureAction(page_action.PageAction):
else: else:
self.wait_action = None self.wait_action = None
assert self.wait_until is None or self.wait_action is None, (
'gesture cannot have wait_after and wait_until at the same time.')
def RunAction(self, tab): def RunAction(self, tab):
if self.wait_action: if self.wait_action:
interaction_name = 'Action_%s' % self.__class__.__name__ interaction_name = 'Action_%s' % self.__class__.__name__
......
# Copyright 2014 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.actions import javascript_click
from telemetry.page.actions import wait_until
from telemetry.unittest import tab_test_case
class ClickElementActionTest(tab_test_case.TabTestCase):
def testClickWithSelectorWaitForNavigation(self):
self.Navigate('page_with_link.html')
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/page_with_link.html')
data = {'selector': 'a[id="clickme"]'}
i = javascript_click.ClickElementAction(data)
data = {'condition': 'href_change'}
j = wait_until.WaitUntil(i, data)
j.RunActionAndWait(self._tab)
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/blank.html')
def testClickWithSingleQuoteSelectorWaitForNavigation(self):
self.Navigate('page_with_link.html')
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/page_with_link.html')
data = {'selector': 'a[id=\'clickme\']'}
i = javascript_click.ClickElementAction(data)
data = {'condition': 'href_change'}
j = wait_until.WaitUntil(i, data)
j.RunActionAndWait(self._tab)
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/blank.html')
def testClickWithTextWaitForRefChange(self):
self.Navigate('page_with_link.html')
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/page_with_link.html')
data = {'text': 'Click me'}
i = javascript_click.ClickElementAction(data)
data = {'condition': 'href_change'}
j = wait_until.WaitUntil(i, data)
j.RunActionAndWait(self._tab)
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/blank.html')
def testClickWithXPathWaitForRefChange(self):
self.Navigate('page_with_link.html')
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/page_with_link.html')
data = {'xpath': '//a[@id="clickme"]'}
i = javascript_click.ClickElementAction(data)
data = {'condition': 'href_change'}
j = wait_until.WaitUntil(i, data)
j.RunActionAndWait(self._tab)
self.assertEquals(
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/blank.html')
# Copyright 2012 The Chromium Authors. All rights reserved. # Copyright 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from telemetry.page.actions import wait_until
class PageActionNotSupported(Exception): class PageActionNotSupported(Exception):
pass pass
...@@ -17,25 +16,12 @@ class PageAction(object): ...@@ -17,25 +16,12 @@ class PageAction(object):
if attributes: if attributes:
for k, v in attributes.iteritems(): for k, v in attributes.iteritems():
setattr(self, k, v) setattr(self, k, v)
if hasattr(self, 'wait_until'):
self.wait_until = wait_until.WaitUntil(self, self.wait_until)
else:
self.wait_until = None
def WillRunAction(self, tab): def WillRunAction(self, tab):
"""Override to do action-specific setup before """Override to do action-specific setup before
Test.WillRunAction is called.""" Test.WillRunAction is called."""
pass pass
def WillWaitAfterRun(self):
return self.wait_until is not None
def RunActionAndMaybeWait(self, tab):
if self.wait_until:
self.wait_until.RunActionAndWait(tab)
else:
self.RunAction(tab)
def RunAction(self, tab): def RunAction(self, tab):
raise NotImplementedError() raise NotImplementedError()
......
# Copyright 2014 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.
class WaitUntil(object):
def __init__(self, previous_action, attributes=None):
assert previous_action is not None, 'wait_until must have a previous action'
self.timeout = 60
if attributes:
for k, v in attributes.iteritems():
setattr(self, k, v)
self._previous_action = previous_action
def RunActionAndWait(self, tab):
if getattr(self, 'condition', None) == 'href_change':
self._previous_action.WillRunAction(tab)
old_url = tab.EvaluateJavaScript('document.location.href')
self._previous_action.RunAction(tab)
tab.WaitForJavaScriptExpression(
'document.location.href != "%s"' % old_url, self.timeout)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment