Exemplo n.º 1
0
    def test_setParentNoChangeNoNotify(self):
        a = self.newSysClock(tickRate=1000)
        b = CorrelatedClock(a, 1000, correlation=Correlation(0, 0))
        c = CorrelatedClock(a, 1000, correlation=Correlation(10, 0))
        d = MockDependent()
        b.bind(d)

        d.assertNotNotified()
        b.setParent(a)
        d.assertNotNotified()
        self.assertEquals(b.getParent(), a)
Exemplo n.º 2
0
    def test_setCorrelationAndSpeed(self):
        a = self.newSysClock(tickRate=1000000)
        b = CorrelatedClock(a, 1000, correlation=Correlation(0, 0))
        b.speed = 1.0

        db = MockDependent()
        b.bind(db)

        b.setCorrelationAndSpeed(Correlation(5, 0), 2)
        db.assertNotificationsEqual([b])
        self.assertEqual(b.toParentTicks(10), 5005)
Exemplo n.º 3
0
    def test_setParent(self):
        a = self.newSysClock(tickRate=1000)
        b = CorrelatedClock(a, 1000, correlation=Correlation(0, 0))
        c = CorrelatedClock(a, 1000, correlation=Correlation(10, 0))
        d = MockDependent()
        b.bind(d)

        d.assertNotNotified()
        b.setParent(c)
        d.assertNotificationsEqual([b])
        self.assertEquals(b.getParent(), c)
Exemplo n.º 4
0
    def test_changeSpeedeNotifies(self):
        """Check a change to the correlation propagates notifications to dependents of this clock"""
        b = self.newSysClock()
        c = CorrelatedClock(b, 1000, correlation=Correlation(0, 300))
        cc = CorrelatedClock(c, 50)

        d1 = MockDependent()
        d2 = MockDependent()
        d3 = MockDependent()

        b.bind(d1)
        c.bind(d2)
        cc.bind(d3)

        c.speed = 0.5

        d1.assertNotNotified()
        d2.assertNotificationsEqual([c])
        d3.assertNotificationsEqual([cc])
Exemplo n.º 5
0
 def test_changeSpeedeNotifies(self):
     """Check a change to the correlation propagates notifications to dependents of this clock"""
     b = SysClock()
     c = CorrelatedClock(b, 1000, correlation=(0,300))
     cc = CorrelatedClock(c, 50)
     
     d1 = MockDependent()
     d2 = MockDependent()
     d3 = MockDependent()
     
     b.bind(d1)
     c.bind(d2)
     cc.bind(d3)
     
     c.speed = 0.5
     
     d1.assertNotNotified()
     d2.assertNotificationsEqual([c])
     d3.assertNotificationsEqual([cc])
Exemplo n.º 6
0
    def test_changeFreqNotifies(self):
        mockTime = self.mockTime

        mockTime.timeNow = 5020.8
        
        b = SysClock()
        c = CorrelatedClock(b, 1000, correlation=(50,300))
        cc = CorrelatedClock(c, 50)
        
        d1 = MockDependent()
        d2 = MockDependent()
        d3 = MockDependent()
        
        b.bind(d1)
        c.bind(d2)
        cc.bind(d3)
        
        c.tickRate = 500
        
        d1.assertNotNotified()
        d2.assertNotificationsEqual([c])
        d3.assertNotificationsEqual([cc])
Exemplo n.º 7
0
    def test_changeFreqNotifies(self):
        mockTime = self.mockTime

        b = self.newSysClock()

        mockTime.timeNow = 5020.8

        c = CorrelatedClock(b, 1000, correlation=Correlation(50, 300))
        cc = CorrelatedClock(c, 50)

        d1 = MockDependent()
        d2 = MockDependent()
        d3 = MockDependent()

        b.bind(d1)
        c.bind(d2)
        cc.bind(d3)

        c.tickRate = 500

        d1.assertNotNotified()
        d2.assertNotificationsEqual([c])
        d3.assertNotificationsEqual([cc])
Exemplo n.º 8
0
    def test_availabilityPropagation(self):
        a = self.newSysClock()
        b = CorrelatedClock(a, 1000)
        c = CorrelatedClock(b, 2000)
        d = CorrelatedClock(c, 3000)

        da = MockDependent()
        db = MockDependent()
        dc = MockDependent()
        dd = MockDependent()

        a.bind(da)
        b.bind(db)
        c.bind(dc)
        d.bind(dd)

        self.assertTrue(a.isAvailable())
        self.assertTrue(b.isAvailable())
        self.assertTrue(c.isAvailable())
        self.assertTrue(d.isAvailable())

        c.setAvailability(False)
        self.assertTrue(a.isAvailable())
        self.assertTrue(b.isAvailable())
        self.assertFalse(c.isAvailable())
        self.assertFalse(d.isAvailable())
        da.assertNotNotified()
        db.assertNotNotified()
        dc.assertNotificationsEqual([c])
        dd.assertNotificationsEqual([d])

        d.setAvailability(False)
        self.assertTrue(a.isAvailable())
        self.assertTrue(b.isAvailable())
        self.assertFalse(c.isAvailable())
        self.assertFalse(d.isAvailable())
        da.assertNotNotified()
        db.assertNotNotified()
        dc.assertNotNotified()
        dd.assertNotNotified()

        c.setAvailability(True)
        self.assertTrue(a.isAvailable())
        self.assertTrue(b.isAvailable())
        self.assertTrue(c.isAvailable())
        self.assertFalse(d.isAvailable())
        da.assertNotNotified()
        db.assertNotNotified()
        dc.assertNotificationsEqual([c])
        dd.assertNotificationsEqual([d])