aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-01-06 16:23:16 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:51:44 -0300
commit42e52dec9cd5db837a9fda2663b9c873dac1cd7b (patch)
tree3f8ff0ea4da6294554a7a1821f20915548903e96 /tests
parent44b71a0ff22cf724b394003131b344ff013a0886 (diff)
Refactoring to Phonon basic playing test.
Also replaced the ogg audio tone file for a wav one. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/phonon/basic_playing_test.py58
-rw-r--r--tests/phonon/tone.oggbin4300 -> 0 bytes
-rw-r--r--tests/phonon/tone.wavbin0 -> 8942 bytes
3 files changed, 26 insertions, 32 deletions
diff --git a/tests/phonon/basic_playing_test.py b/tests/phonon/basic_playing_test.py
index 4eb2ccdd7..49df7d51e 100644
--- a/tests/phonon/basic_playing_test.py
+++ b/tests/phonon/basic_playing_test.py
@@ -1,34 +1,35 @@
import os
import unittest
+from PySide.phonon import Phonon
+from helper import UsesQCoreApplication
-from PySide import QtCore
-from PySide import phonon
+sample_file = os.path.join(os.path.dirname(__file__), 'tone.wav')
-from helper import UsesQCoreApplication
+def checkBackendCapabilities(func):
+ def function(self, *args, **kw):
+ if Phonon.BackendCapabilities.isMimeTypeAvailable('audio/x-wav'):
+ func(self, *args, **kw)
+ else:
+ print 'Wav format not supported! Playback test skipped!'
+ return function
-# XXX Hack to get the correct filename
-example_file = os.path.join(os.path.dirname(__file__),'tone.ogg')
class TestSimplePlaying(UsesQCoreApplication):
def setUp(self):
super(TestSimplePlaying, self).setUp()
self.app.setApplicationName('Dummy')
- self.source = phonon.Phonon.MediaSource(example_file)
- self.media = phonon.Phonon.MediaObject()
+ self.source = Phonon.MediaSource(sample_file)
+ self.media = Phonon.MediaObject()
self.media.setCurrentSource(self.source)
- QtCore.QObject.connect(self.media,
- QtCore.SIGNAL('finished()'),
- self.app,
- QtCore.SLOT('quit()'))
-
+ self.media.finished.connect(self.app.quit)
self.called = False
# prevent locking with:
# request to play a stream, but no valid audio ...
- self.output = phonon.Phonon.AudioOutput()
- self.path = phonon.Phonon.createPath(self.media, self.output)
+ self.output = Phonon.AudioOutput()
+ self.path = Phonon.createPath(self.media, self.output)
def tearDown(self):
super(TestSimplePlaying, self).tearDown()
@@ -37,14 +38,11 @@ class TestSimplePlaying(UsesQCoreApplication):
del self.media
del self.source
+ @checkBackendCapabilities
def testFinishedSignal(self):
- # Check for ogg support before playing it
- if (phonon.Phonon.BackendCapabilities.isMimeTypeAvailable('audio/ogg')):
- # Should pass if finished() is called
- self.media.play()
- self.app.exec_()
- else:
- print 'Ogg format not supported! Playback test skipped!'
+ # Should pass if finished() is called
+ self.media.play()
+ self.app.exec_()
def testMediaSource(self):
self.assertEqual(self.media.currentSource(), self.source)
@@ -57,18 +55,14 @@ class TestSimplePlaying(UsesQCoreApplication):
def state_cb(self, newState, OldState):
self.called = True
+ @checkBackendCapabilities
def testStateChanged(self):
- # Check for ogg support before playing it
- if (phonon.Phonon.BackendCapabilities.isMimeTypeAvailable('audio/ogg')):
- QtCore.QObject.connect(self.media,
- QtCore.SIGNAL('stateChanged(Phonon::State, Phonon::State)'),
- self.state_cb)
-
- self.media.play()
- self.app.exec_()
- self.assert_(self.called)
- else:
- print 'Ogg format not supported! Playback test skipped!'
+ self.media.stateChanged['Phonon::State', 'Phonon::State'].connect(self.state_cb)
+ self.media.play()
+ self.app.exec_()
+ self.assert_(self.called)
+
if __name__ == '__main__':
unittest.main()
+
diff --git a/tests/phonon/tone.ogg b/tests/phonon/tone.ogg
deleted file mode 100644
index dc1a455d3..000000000
--- a/tests/phonon/tone.ogg
+++ /dev/null
Binary files differ
diff --git a/tests/phonon/tone.wav b/tests/phonon/tone.wav
new file mode 100644
index 000000000..2fa06a72a
--- /dev/null
+++ b/tests/phonon/tone.wav
Binary files differ