davemds pushed a commit to branch master.
commit 8df1784275126ce767e89ef3abcbc9207ba09e81
Author: davemds <[email protected]>
Date: Sun Apr 7 01:30:31 2013 +0200
Python-EFL: first unittest for the dbus mainloop integration
---
tests/dbus/00_run_all_tests.py | 9 +++++++++
tests/dbus/test_01_basics.py | 43 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/tests/dbus/00_run_all_tests.py b/tests/dbus/00_run_all_tests.py
new file mode 100644
index 0000000..24dd275
--- /dev/null
+++ b/tests/dbus/00_run_all_tests.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+import unittest
+
+
+loader = unittest.TestLoader()
+suite = loader.discover('.')
+runner = unittest.TextTestRunner(verbosity=2)
+result = runner.run(suite)
diff --git a/tests/dbus/test_01_basics.py b/tests/dbus/test_01_basics.py
new file mode 100644
index 0000000..20e2944
--- /dev/null
+++ b/tests/dbus/test_01_basics.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+import dbus
+import dbus.service
+from efl.dbus_mainloop import DBusEcoreMainLoop
+from efl import ecore
+import unittest
+
+
+class TestDBusBasics(unittest.TestCase):
+ def setUp(self):
+ self.bus = dbus.SessionBus(mainloop=DBusEcoreMainLoop())
+
+ def tearDown(self):
+ pass
+
+ def testSignalReceiver(self):
+ self.received = False
+
+ def name_owner_changed_cb(name, old_owner, new_owner):
+ if name == "org.efl.TestService":
+ # name received...good, quit the test now!
+ self.received = True
+ ecore.main_loop_quit()
+
+ # receive notification on name changes
+ self.bus.add_signal_receiver(name_owner_changed_cb,
+ signal_name="NameOwnerChanged")
+
+ # claim the name 'org.efl.TestService'
+ self.name = dbus.service.BusName("org.efl.TestService", self.bus)
+
+ # start the ecore mainloop and wait at max 1.5 seconds
+ ecore.Timer(1.5, lambda: ecore.main_loop_quit())
+ ecore.main_loop_begin()
+
+ # did we received the signal ?
+ self.assertTrue(self.received)
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
+ ecore.shutdown()
--
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html