1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4############################################################################# 5## 6## Copyright (C) 2016 The Qt Company Ltd. 7## Contact: https://www.qt.io/licensing/ 8## 9## This file is part of the test suite of Qt for Python. 10## 11## $QT_BEGIN_LICENSE:GPL-EXCEPT$ 12## Commercial License Usage 13## Licensees holding valid commercial Qt licenses may use this file in 14## accordance with the commercial license agreement provided with the 15## Software or, alternatively, in accordance with the terms contained in 16## a written agreement between you and The Qt Company. For licensing terms 17## and conditions see https://www.qt.io/terms-conditions. For further 18## information use the contact form at https://www.qt.io/contact-us. 19## 20## GNU General Public License Usage 21## Alternatively, this file may be used under the terms of the GNU 22## General Public License version 3 as published by the Free Software 23## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 24## included in the packaging of this file. Please review the following 25## information to ensure the GNU General Public License requirements will 26## be met: https://www.gnu.org/licenses/gpl-3.0.html. 27## 28## $QT_END_LICENSE$ 29## 30############################################################################# 31 32import os 33import sys 34import unittest 35 36sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 37from init_paths import init_test_paths 38init_test_paths(False) 39 40from PySide2.QtCore import QObject, QCoreApplication, QTimeLine, Signal, Slot 41from helper.usesqcoreapplication import UsesQCoreApplication 42 43class ExtQObject(QObject): 44 signalbetween = Signal('qreal') 45 46 def __init__(self): 47 QObject.__init__(self) 48 self.counter = 0 49 50 @Slot('qreal') 51 def foo(self, value): 52 self.counter += 1 53 54 55class SignaltoSignalTest(UsesQCoreApplication): 56 57 def setUp(self): 58 UsesQCoreApplication.setUp(self) 59 self.receiver = ExtQObject() 60 self.timeline = QTimeLine(100) 61 62 def tearDown(self): 63 del self.timeline 64 del self.receiver 65 UsesQCoreApplication.tearDown(self) 66 67 def testSignaltoSignal(self): 68 self.timeline.setUpdateInterval(10) 69 70 self.timeline.finished.connect(self.app.quit) 71 72 self.timeline.valueChanged.connect(self.receiver.signalbetween) 73 self.receiver.signalbetween.connect(self.receiver.foo) 74 75 self.timeline.start() 76 77 self.app.exec_() 78 79 self.assertTrue(self.receiver.counter > 1) 80 81 82if __name__ == '__main__': 83 unittest.main() 84 85