X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftools%2Ftelemetry%2Ftelemetry%2Fpage%2Factions%2Fseek.py;h=1d12693a4d3c9668c7a6a7956f6b8ae77b2e68c2;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=bdc25f2d7954f2300fce88b065b1bf41ed73d2e3;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/tools/telemetry/telemetry/page/actions/seek.py b/src/tools/telemetry/telemetry/page/actions/seek.py index bdc25f2..1d12693 100644 --- a/src/tools/telemetry/telemetry/page/actions/seek.py +++ b/src/tools/telemetry/telemetry/page/actions/seek.py @@ -4,18 +4,17 @@ """A Telemetry page_action that performs the "seek" action on media elements. -Action attributes are: -- seek_time: The media time to seek to. Test fails if not provided. +Action parameters are: +- seconds: The media time to seek to. Test fails if not provided. - selector: If no selector is defined then the action attempts to seek the first media element on the page. If 'all' then seek all media elements. -- log_seek_time: If true the seek time is recorded, otherwise media measurement - will not be aware of the seek action. Used to perform multiple - seeks. Default true. -- wait_for_seeked: If true forces the action to wait for seeked event to fire. - Default false. -- wait_timeout: Timeout to wait for seeked event. Only valid with - wait_for_seeked=true -- seek_label: A suffix string to name the seek perf measurement. +- timeout_in_seconds: Maximum waiting time for the "seeked" event + (dispatched when the seeked operation completes) + to be fired. 0 means do not wait. +- log_time: If true the seek time is recorded, otherwise media + measurement will not be aware of the seek action. Used to + perform multiple seeks. Default true. +- label: A suffix string to name the seek perf measurement. """ from telemetry.core import exceptions @@ -24,6 +23,15 @@ from telemetry.page.actions import page_action class SeekAction(media_action.MediaAction): + def __init__(self, seconds, selector=None, timeout_in_seconds=0, + log_time=True, label=''): + super(SeekAction, self).__init__() + self._seconds = seconds + self._selector = selector if selector else '' + self._timeout_in_seconds = timeout_in_seconds + self._log_time = log_time + self._label = label + def WillRunAction(self, tab): """Load the media metrics JS code prior to running the action.""" super(SeekAction, self).WillRunAction(tab) @@ -31,16 +39,12 @@ class SeekAction(media_action.MediaAction): def RunAction(self, tab): try: - assert hasattr(self, 'seek_time') - selector = self.selector if hasattr(self, 'selector') else '' - log_seek = self.log_seek == True if hasattr(self, 'log_seek') else True - seek_label = self.seek_label if hasattr(self, 'seek_label') else '' - tab.ExecuteJavaScript('window.__seekMedia("%s", "%s", %i, "%s");' % - (selector, self.seek_time, log_seek, seek_label)) - timeout = self.wait_timeout if hasattr(self, 'wait_timeout') else 60 - # Check if we need to wait for 'seeked' event to fire. - if hasattr(self, 'wait_for_seeked') and self.wait_for_seeked: - self.WaitForEvent(tab, selector, 'seeked', timeout) + tab.ExecuteJavaScript( + 'window.__seekMedia("%s", "%s", %i, "%s");' % + (self._selector, self._seconds, self._log_time, self._label)) + if self._timeout_in_seconds > 0: + self.WaitForEvent(tab, self._selector, 'seeked', + self._timeout_in_seconds) except exceptions.EvaluateException: raise page_action.PageActionFailed('Cannot seek media element(s) with ' - 'selector = %s.' % selector) + 'selector = %s.' % self._selector)