aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phonon
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-09-21 14:51:26 -0300
committerHugo Lima <hugo.lima@openbossa.org>2009-09-21 14:52:09 -0300
commit9af36fbb64f19842c0cc797c0b586b3a686805e8 (patch)
tree6bbc050ded0f85517ea75f5dc6dc1ed172168248 /tests/phonon
parentaa12538d63685ef8f75adaa79411b751929b727d (diff)
Added all original pyside unit tests to the shiboken version.
Diffstat (limited to 'tests/phonon')
-rw-r--r--tests/phonon/basic_playing_test.py60
-rw-r--r--tests/phonon/capabilities_test.py48
-rw-r--r--tests/phonon/tone.oggbin0 -> 4300 bytes
3 files changed, 108 insertions, 0 deletions
diff --git a/tests/phonon/basic_playing_test.py b/tests/phonon/basic_playing_test.py
new file mode 100644
index 000000000..100a036c0
--- /dev/null
+++ b/tests/phonon/basic_playing_test.py
@@ -0,0 +1,60 @@
+
+import os
+import unittest
+
+from PySide import QtCore
+from PySide import phonon
+
+from helper import UsesQCoreApplication
+
+# 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.media.setCurrentSource(self.source)
+
+ QtCore.QObject.connect(self.media,
+ QtCore.SIGNAL('finished()'),
+ self.app,
+ QtCore.SLOT('quit()'))
+
+ self.called = False
+
+ def tearDown(self):
+ super(TestSimplePlaying, self).tearDown()
+
+ def testFinishedSignal(self):
+ # Should pass if finished() is called
+ self.media.play()
+ self.app.exec_()
+
+ def testMediaSource(self):
+ self.assertEqual(self.media.currentSource(), self.source)
+
+ def testPathCreation(self):
+ output = phonon.Phonon.AudioOutput()
+ path = phonon.Phonon.createPath(self.media, output)
+
+ # FIXME Both functions below are not exported by PyQt4
+ self.assertEqual(path.sink(), output)
+ self.assertEqual(path.source(), self.media)
+
+ def state_cb(self, newState, OldState):
+ self.called = True
+
+ def testStateChanged(self):
+ 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)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/phonon/capabilities_test.py b/tests/phonon/capabilities_test.py
new file mode 100644
index 000000000..5f4b7da83
--- /dev/null
+++ b/tests/phonon/capabilities_test.py
@@ -0,0 +1,48 @@
+
+import unittest
+
+from PySide.QtCore import QString
+from PySide import phonon
+
+from helper import UsesQCoreApplication
+
+class CapabilitiesTest(UsesQCoreApplication):
+ def setUp(self):
+ super(CapabilitiesTest, self).setUp()
+ self.app.setApplicationName("Dummy")
+
+ def tearDown(self):
+ super(CapabilitiesTest, self).tearDown()
+
+
+ def testExists(self):
+ self.assert_(phonon.Phonon.BackendCapabilities)
+
+ def testNotifierIdentity(self):
+ # Notifier is a singleton
+ self.assertEqual(phonon.Phonon.BackendCapabilities.notifier(),
+ phonon.Phonon.BackendCapabilities.notifier())
+
+ self.assert_(phonon.Phonon.BackendCapabilities.notifier() is
+ phonon.Phonon.BackendCapabilities.notifier())
+
+ def testDevices(self):
+ # TODO Improve this test
+ devices = phonon.Phonon.BackendCapabilities.availableAudioOutputDevices()
+ for device in devices:
+ self.assert_(isinstance(device, phonon.Phonon.AudioOutputDevice))
+
+ def testMimeTypes(self):
+ # TODO Improve this test
+ mimeTypes = phonon.Phonon.BackendCapabilities.availableMimeTypes()
+ for mime in mimeTypes:
+ self.assert_(isinstance(mime, QString))
+
+ def testAudioEffects(self):
+ # TODO Improve this test
+ effects = phonon.Phonon.BackendCapabilities.availableAudioEffects()
+ for effect in effects:
+ self.assert_(isinstance(effect, phonon.Phonon.EffectDescription))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/phonon/tone.ogg b/tests/phonon/tone.ogg
new file mode 100644
index 000000000..dc1a455d3
--- /dev/null
+++ b/tests/phonon/tone.ogg
Binary files differ