Update unit test for static metaobjet to work with new optimizations

Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
          Lauro Neto <lauro.neto@openbossa.org>
This commit is contained in:
Renato Filho 2011-07-21 17:52:28 -03:00
commit d9ce3c55f6

View file

@ -2,12 +2,10 @@
"""Tests covering signal emission and receiving to python slots""" """Tests covering signal emission and receiving to python slots"""
import sys
import unittest import unittest
import functools
from PySide.QtCore import * from PySide.QtCore import QObject, SIGNAL
from helper import BasicPySlotCase, UsesQCoreApplication from helper import UsesQCoreApplication
class MyObject(QObject): class MyObject(QObject):
def __init__(self, parent=None): def __init__(self, parent=None):
@ -24,27 +22,21 @@ class StaticMetaObjectTest(UsesQCoreApplication):
o = MyObject() o = MyObject()
o2 = MyObject() o2 = MyObject()
m = o.metaObject()
# SIGNAL foo not created yet # SIGNAL foo not created yet
self.assertEqual(m.indexOfSignal("foo()"), -1) self.assertEqual(o.metaObject().indexOfSignal("foo()"), -1)
o.connect(SIGNAL("foo()"), o2.mySlot) o.connect(SIGNAL("foo()"), o2.mySlot)
# SIGNAL foo create after connect # SIGNAL foo create after connect
self.assert_(m.indexOfSignal("foo()") > 0) self.assert_(o.metaObject().indexOfSignal("foo()") > 0)
m = o2.metaObject() # SIGNAL does not propagate to others objects of the same type
# SIGNAL propagate to others objects of the same type self.assertEqual(o2.metaObject().indexOfSignal("foo()"), -1)
self.assert_(m.indexOfSignal("foo()") > 0)
del o del o
# SIGNAL foo continues registered after deletion of original object
self.assert_(m.indexOfSignal("foo()") > 0)
del o2 del o2
o = MyObject() o = MyObject()
m = o.metaObject() # The SIGNAL was destroyed with old objects
# new objects still have the SIGNAL foo registered self.assertEqual(o.metaObject().indexOfSignal("foo()"), -1)
self.assert_(m.indexOfSignal("foo()") > 0)
def testSharedSignalEmission(self): def testSharedSignalEmission(self):