mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
testsuite/event.py, testsuite/buffer.py: New tests.
Original commit message from CVS: * testsuite/event.py, testsuite/buffer.py: New tests. * testsuite/common.py (run_silent): New function to enable stderr even if an exception is raised. * testsuite/element.py (FakeSinkTest.checkError): Better state-error checking.
This commit is contained in:
parent
ed9136fd26
commit
54cab73355
8 changed files with 130 additions and 15 deletions
|
@ -1,5 +1,13 @@
|
|||
2004-05-03 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* testsuite/event.py, testsuite/buffer.py: New tests.
|
||||
|
||||
* testsuite/common.py (run_silent): New function to enable stderr
|
||||
even if an exception is raised.
|
||||
|
||||
* testsuite/element.py (FakeSinkTest.checkError): Better
|
||||
state-error checking.
|
||||
|
||||
* gst/common.h: Add some parenthesises
|
||||
|
||||
* gst/play.override: Include common.h
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 63d93f01177745ba864263f0b6f976212684cb87
|
||||
Subproject commit 95ba8839c03a7f8939a2ae4b0586b012e929fc84
|
10
testsuite/buffer.py
Normal file
10
testsuite/buffer.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
import sys
|
||||
from common import gst, unittest
|
||||
|
||||
class BufferTest(unittest.TestCase):
|
||||
def testBuffer(self):
|
||||
self.buffer = gst.Buffer('test')
|
||||
assert str(buffer(self.buffer)) == 'test'
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -47,3 +47,16 @@ def enable_stderr():
|
|||
_stderr.close()
|
||||
os.remove('/tmp/stderr')
|
||||
return data
|
||||
|
||||
def run_silent(function, *args, **kwargs):
|
||||
disable_stderr()
|
||||
|
||||
try:
|
||||
function(*args, **kwargs)
|
||||
except Exception, exc:
|
||||
enable_stderr()
|
||||
raise exc
|
||||
|
||||
output = enable_stderr()
|
||||
|
||||
return output
|
||||
|
|
|
@ -33,20 +33,48 @@ class FakeSinkTest(ElementTest):
|
|||
def setUp(self):
|
||||
self.element = gst.Element('fakesink', 'sink')
|
||||
|
||||
def testStateError(self):
|
||||
self.element.set_property('state-error',
|
||||
self.FAKESINK_STATE_ERROR_NULL_READY)
|
||||
def checkError(self, old_state, state, name):
|
||||
assert self.element.get_state() == gst.STATE_NULL
|
||||
assert self.element.set_state(old_state)
|
||||
assert self.element.get_state() == old_state
|
||||
|
||||
self.element.set_property('state-error', name)
|
||||
def error_cb(element, source, error, debug):
|
||||
assert isinstance(element, gst.Element)
|
||||
assert element == self.element
|
||||
assert isinstance(source, gst.Element)
|
||||
assert source == self.element
|
||||
assert isinstance(error, gst.GError)
|
||||
|
||||
|
||||
self.element.connect('error', error_cb)
|
||||
common.disable_stderr()
|
||||
self.element.set_state(gst.STATE_READY)
|
||||
common.enable_stderr()
|
||||
error_message = common.run_silent(self.element.set_state, state)
|
||||
|
||||
assert error_message.find('ERROR') != -1
|
||||
self.element.get_state() == old_state, 'state changed'
|
||||
|
||||
def testStateErrorNullReady(self):
|
||||
self.checkError(gst.STATE_NULL, gst.STATE_READY,
|
||||
self.FAKESINK_STATE_ERROR_NULL_READY)
|
||||
|
||||
def testStateErrorReadyPaused(self):
|
||||
self.checkError(gst.STATE_READY, gst.STATE_PAUSED,
|
||||
self.FAKESINK_STATE_ERROR_READY_PAUSED)
|
||||
|
||||
def testStateErrorPausedPlaying(self):
|
||||
self.checkError(gst.STATE_PAUSED, gst.STATE_PLAYING,
|
||||
self.FAKESINK_STATE_ERROR_PAUSED_PLAYING)
|
||||
|
||||
def testStateErrorPlayingPaused(self):
|
||||
self.checkError(gst.STATE_PLAYING, gst.STATE_PAUSED,
|
||||
self.FAKESINK_STATE_ERROR_PLAYING_PAUSED)
|
||||
|
||||
def testStateErrorPausedReady(self):
|
||||
self.checkError(gst.STATE_PAUSED, gst.STATE_READY,
|
||||
self.FAKESINK_STATE_ERROR_PAUSED_READY)
|
||||
|
||||
def testStateErrorReadyNull(self):
|
||||
self.checkError(gst.STATE_READY, gst.STATE_NULL,
|
||||
self.FAKESINK_STATE_ERROR_READY_NULL)
|
||||
|
||||
class NonExistentTest(ElementTest):
|
||||
name = 'this-element-does-not-exist'
|
||||
|
|
18
testsuite/event.py
Normal file
18
testsuite/event.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import sys
|
||||
from common import gst, unittest
|
||||
|
||||
class EventTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pipeline = gst.parse_launch('fakesrc ! fakesink name=sink')
|
||||
self.sink = pipeline.get_by_name('sink')
|
||||
|
||||
def testEventEmpty(self):
|
||||
event = gst.Event(gst.EVENT_EMPTY)
|
||||
self.sink.send_event(event)
|
||||
|
||||
def testEventSeek(self):
|
||||
event = gst.event_new_seek(gst.SEEK_METHOD_CUR, 0)
|
||||
self.sink.send_event(event)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
10
testsuite/test_buffer.py
Normal file
10
testsuite/test_buffer.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
import sys
|
||||
from common import gst, unittest
|
||||
|
||||
class BufferTest(unittest.TestCase):
|
||||
def testBuffer(self):
|
||||
self.buffer = gst.Buffer('test')
|
||||
assert str(buffer(self.buffer)) == 'test'
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
|
@ -33,20 +33,48 @@ class FakeSinkTest(ElementTest):
|
|||
def setUp(self):
|
||||
self.element = gst.Element('fakesink', 'sink')
|
||||
|
||||
def testStateError(self):
|
||||
self.element.set_property('state-error',
|
||||
self.FAKESINK_STATE_ERROR_NULL_READY)
|
||||
def checkError(self, old_state, state, name):
|
||||
assert self.element.get_state() == gst.STATE_NULL
|
||||
assert self.element.set_state(old_state)
|
||||
assert self.element.get_state() == old_state
|
||||
|
||||
self.element.set_property('state-error', name)
|
||||
def error_cb(element, source, error, debug):
|
||||
assert isinstance(element, gst.Element)
|
||||
assert element == self.element
|
||||
assert isinstance(source, gst.Element)
|
||||
assert source == self.element
|
||||
assert isinstance(error, gst.GError)
|
||||
|
||||
|
||||
self.element.connect('error', error_cb)
|
||||
common.disable_stderr()
|
||||
self.element.set_state(gst.STATE_READY)
|
||||
common.enable_stderr()
|
||||
error_message = common.run_silent(self.element.set_state, state)
|
||||
|
||||
assert error_message.find('ERROR') != -1
|
||||
self.element.get_state() == old_state, 'state changed'
|
||||
|
||||
def testStateErrorNullReady(self):
|
||||
self.checkError(gst.STATE_NULL, gst.STATE_READY,
|
||||
self.FAKESINK_STATE_ERROR_NULL_READY)
|
||||
|
||||
def testStateErrorReadyPaused(self):
|
||||
self.checkError(gst.STATE_READY, gst.STATE_PAUSED,
|
||||
self.FAKESINK_STATE_ERROR_READY_PAUSED)
|
||||
|
||||
def testStateErrorPausedPlaying(self):
|
||||
self.checkError(gst.STATE_PAUSED, gst.STATE_PLAYING,
|
||||
self.FAKESINK_STATE_ERROR_PAUSED_PLAYING)
|
||||
|
||||
def testStateErrorPlayingPaused(self):
|
||||
self.checkError(gst.STATE_PLAYING, gst.STATE_PAUSED,
|
||||
self.FAKESINK_STATE_ERROR_PLAYING_PAUSED)
|
||||
|
||||
def testStateErrorPausedReady(self):
|
||||
self.checkError(gst.STATE_PAUSED, gst.STATE_READY,
|
||||
self.FAKESINK_STATE_ERROR_PAUSED_READY)
|
||||
|
||||
def testStateErrorReadyNull(self):
|
||||
self.checkError(gst.STATE_READY, gst.STATE_NULL,
|
||||
self.FAKESINK_STATE_ERROR_READY_NULL)
|
||||
|
||||
class NonExistentTest(ElementTest):
|
||||
name = 'this-element-does-not-exist'
|
||||
|
|
Loading…
Reference in a new issue