def testTemporalRange(self):
        p = QgsProjectTimeSettings()
        self.assertTrue(p.temporalRange().isInfinite())
        spy = QSignalSpy(p.temporalRangeChanged)

        r = QgsDateTimeRange(QDateTime(QDate(2020, 1, 1), QTime(8, 0, 0)),
                             QDateTime(QDate(2020, 12, 1), QTime(8, 0, 0)))

        rc = QgsDateTimeRange(QDateTime(QDate(2020, 1, 1), QTime(8, 0, 0)),
                              QDateTime(QDate(2020, 12, 1), QTime(8, 0, 0)))

        p.setTemporalRange(r)
        self.assertEqual(p.temporalRange(), r)
        self.assertEqual(len(spy), 1)

        p.setTemporalRange(rc)
        self.assertEqual(len(spy), 1)

        p.reset()
        self.assertEqual(len(spy), 2)
    def testReadWrite(self):
        p = QgsProjectTimeSettings()
        self.assertTrue(p.temporalRange().isInfinite())
        doc = QDomDocument("testdoc")
        elem = p.writeXml(doc, QgsReadWriteContext())

        p2 = QgsProjectTimeSettings()
        spy = QSignalSpy(p2.temporalRangeChanged)
        self.assertTrue(p2.readXml(elem, QgsReadWriteContext()))
        self.assertEqual(p2.temporalRange(), p.temporalRange())
        self.assertEqual(len(spy), 0)

        r = QgsDateTimeRange(
            QDateTime(QDate(2020, 1, 1), QTime(8, 0, 0)),
            QDateTime(QDate(2020, 12, 1), QTime(8, 0, 0))
        )
        p.setTemporalRange(r)
        p.setTimeStep(4.8)
        p.setTimeStepUnit(QgsUnitTypes.TemporalDecades)
        p.setFramesPerSecond(90)
        elem = p.writeXml(doc, QgsReadWriteContext())

        p2 = QgsProjectTimeSettings()
        spy = QSignalSpy(p2.temporalRangeChanged)
        self.assertTrue(p2.readXml(elem, QgsReadWriteContext()))
        self.assertEqual(p2.temporalRange(), r)
        self.assertEqual(len(spy), 1)
        self.assertEqual(p2.timeStep(), 4.8)
        self.assertEqual(p2.timeStepUnit(), QgsUnitTypes.TemporalDecades)
        self.assertEqual(p2.framesPerSecond(), 90)
    def testGettersSetters(self):
        p = QgsProjectTimeSettings()

        p.setTimeStep(4.8)
        self.assertEqual(p.timeStep(), 4.8)
        p.setTimeStepUnit(QgsUnitTypes.TemporalDecades)
        self.assertEqual(p.timeStepUnit(), QgsUnitTypes.TemporalDecades)
        p.setFramesPerSecond(90)
        self.assertEqual(p.framesPerSecond(), 90)
    def testReadWrite(self):
        p = QgsProjectTimeSettings()
        self.assertTrue(p.temporalRange().isInfinite())
        doc = QDomDocument("testdoc")
        elem = p.writeXml(doc, QgsReadWriteContext())

        p2 = QgsProjectTimeSettings()
        spy = QSignalSpy(p2.temporalRangeChanged)
        self.assertTrue(p2.readXml(elem, QgsReadWriteContext()))
        self.assertEqual(p2.temporalRange(), p.temporalRange())
        self.assertEqual(len(spy), 0)

        r = QgsDateTimeRange(QDateTime(QDate(2020, 1, 1), QTime(8, 0, 0)),
                             QDateTime(QDate(2020, 12, 1), QTime(8, 0, 0)))
        p.setTemporalRange(r)
        elem = p.writeXml(doc, QgsReadWriteContext())

        p2 = QgsProjectTimeSettings()
        spy = QSignalSpy(p2.temporalRangeChanged)
        self.assertTrue(p2.readXml(elem, QgsReadWriteContext()))
        self.assertEqual(p2.temporalRange(), r)
        self.assertEqual(len(spy), 1)