Ejemplo n.º 1
0
    def testTypedef(self):
        obj = TestObject(0)
        receiver = Receiver()

        obj.signalWithTypedefValue.connect(receiver.slot)
        obj.emitSignalWithTypedefValue(2)
        self.assertEqual(receiver.received.value, 2)
Ejemplo n.º 2
0
 def testConnection(self):
     o = TestObject(0)
     c = QObject()
     c.setObjectName("child")
     self._child = None
     o.childrenChanged.connect(self.childrenChanged)
     o.addChild(c)
     self.assertEquals(self._child.objectName(), "child")
Ejemplo n.º 3
0
    def testReprWithoutNamespace(self):
        """Test that classes outside a namespace that have a operator<<(QDebug,...) defined use that
        for __repr__"""
        t = TestObject(123)

        # We don't define __str__, so str(q) should call __repr__
        self.assertEqual(t.__repr__(), str(t))

        # __repr__ should use the operator<<(QDebug,...) implementation
        self.assertIn('TestObject(id=123)', str(t))
Ejemplo n.º 4
0
    def testDuringCallback(self):
        """ Test to see if the C++ object for a connection is accessed after the
        method returns.  This causes a segfault if the memory that was used by the
        C++ object has been reused. """

        self.called = False
        obj = TestObject(0)

        def callback():
            obj.signalWithDefaultValue.disconnect(callback)

            # Connect more callbacks to try to overwrite memory
            for i in range(1000):
                obj.signalWithDefaultValue.connect(lambda: None)

            self.called = True

            # A non-None return value is needed
            return True

        obj.signalWithDefaultValue.connect(callback)
        obj.signalWithDefaultValue.emit()
        self.assertTrue(self.called)
Ejemplo n.º 5
0
 def testCallingOfDecoratedSlot(self):
     obj = TestObject(0)
     receiver = Receiver()
     obj.staticMethodDouble.connect(receiver.slot)
     obj.emitStaticMethodDoubleSignal()
     self.assertTrue(receiver.called)
 def setUp(self):
     self.obj = TestObject(0)
     self.void_called = False
     self.bool_called = False
Ejemplo n.º 7
0
 def setUp(self):
     self.obj1 = TestObject(0)
     self.obj2 = TestObject(0)
     self.one_called = 0
     self.two_called = 0
 def setUp(self):
     self.value = 123
     self.called = False
     self.obj = TestObject(self.value)