| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Event test base for the HTML5 media tag. | 6 """Event test base for the HTML5 media tag. |
| 7 | 7 |
| 8 This class contains all common code needed for event testing. Most of the | 8 This class contains all common code needed for event testing. Most of the |
| 9 methods should be overridden by the subclass. | 9 methods should be overridden by the subclass. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import pyauto_media | 12 import pyauto_media |
| 13 from media_test_base import MediaTestBase | 13 from media_test_base import MediaTestBase |
| 14 | 14 |
| 15 | 15 |
| 16 class MediaEventTestBase(MediaTestBase): | 16 class MediaEventTestBase(MediaTestBase): |
| 17 """Event test base for the HTML5 media tag.""" | 17 """Event test base for the HTML5 media tag.""" |
| 18 # This is a list of events to test during media playback. | 18 # This is a list of events to test during media playback. |
| 19 EVENT_LIST = ['abort', 'canplay', 'canplaythrough', 'durationchange', | 19 EVENT_LIST = ['abort', 'canplay', 'canplaythrough', 'durationchange', |
| 20 'emptied', 'ended', 'error', 'load', 'loadeddata', | 20 'emptied', 'ended', 'error', 'load', 'loadeddata', |
| 21 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', | 21 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', |
| 22 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', | 22 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', |
| 23 'suspend', 'timeupdate', 'volumechange', 'waiting'] | 23 'suspend', 'timeupdate', 'volumechange', 'waiting', |
| 24 # Track related events |
| 25 'cuechange', 'enter', 'exit', 'change'] |
| 24 # These are event types that are not 1 at the end of video playback. | 26 # These are event types that are not 1 at the end of video playback. |
| 25 # There are two types of events listed here: | 27 # There are two types of events listed here: |
| 26 # 0: event occurrence is 0. | 28 # 0: event occurrence is 0. |
| 27 # None: event occurrence is more than 1. | 29 # None: event occurrence is more than 1. |
| 28 # The following are default values that may be overridden. | 30 # The following are default values that may be overridden. |
| 29 event_expected_values = {'ratechange': 0, | 31 event_expected_values = {'ratechange': 0, |
| 30 'pause': 0, | 32 'pause': 0, |
| 31 'suspend': 0, | 33 'suspend': 0, |
| 32 'load': 0, | 34 'load': 0, |
| 33 'abort': 0, | 35 'abort': 0, |
| 34 'error': 0, | 36 'error': 0, |
| 35 'emptied': 0, | 37 'emptied': 0, |
| 36 'stalled': 0, | 38 'stalled': 0, |
| 37 'seeking': 0, | 39 'seeking': 0, |
| 38 'seeked': 0, | 40 'seeked': 0, |
| 39 'volumechange': 0, | 41 'volumechange': 0, |
| 40 'timeupdate': None} | 42 'timeupdate': None, |
| 43 'cuechange': 0, |
| 44 'enter': 0, |
| 45 'exit': 0, |
| 46 'change': 0} |
| 41 | 47 |
| 42 def _GetEventLog(self): | 48 def _GetEventLog(self): |
| 43 """Get the event log from the DOM tree that is produced by player.html. | 49 """Get the event log from the DOM tree that is produced by player.html. |
| 44 | 50 |
| 45 Returns: | 51 Returns: |
| 46 A dictionary mapping event names to the corresponding occurrence counts. | 52 A dictionary mapping event names to the corresponding occurrence counts. |
| 47 """ | 53 """ |
| 48 all_event_infos = {} | 54 all_event_infos = {} |
| 49 for event_name in self.EVENT_LIST: | 55 for event_name in self.EVENT_LIST: |
| 50 loc = 'document.getElementById(\'%s\').innerHTML' % event_name | 56 loc = 'document.getElementById(\'%s\').innerHTML' % event_name |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 """ | 96 """ |
| 91 MediaTestBase.PostEachRunProcess(self, run_counter) | 97 MediaTestBase.PostEachRunProcess(self, run_counter) |
| 92 all_event_infos = self._GetEventLog() | 98 all_event_infos = self._GetEventLog() |
| 93 # TODO(imasaki@chromium.org): adjust events based on actions. | 99 # TODO(imasaki@chromium.org): adjust events based on actions. |
| 94 if not self._test_scenarios: | 100 if not self._test_scenarios: |
| 95 self.AssertEvent(all_event_infos) | 101 self.AssertEvent(all_event_infos) |
| 96 | 102 |
| 97 def GetPlayerHTMLFileName(self): | 103 def GetPlayerHTMLFileName(self): |
| 98 """A method to get the player HTML file name.""" | 104 """A method to get the player HTML file name.""" |
| 99 return 'media_event.html' | 105 return 'media_event.html' |
| OLD | NEW |