Exemplo n.º 1
0
    def test_global_deactivation(self):
        tracker = Object()
        tracker2 = Object()
        tracked = Object()
        track.PosTrack(tracker, tracked)
        track.PosTrack(tracker2, tracked)
        
        # Deactivate by the tracker
        track.deactivate(tracker=tracker)

        tracked.pos = (1,1,1)
        self.assertEquals((0,0,0), tracker.pos)
        self.assertEquals((1,1,1), tracker2.pos)

        track.deactivate(tracker=tracker2)

        tracked.pos += (1,2,3)
        self.assertEquals((1,1,1), tracker2.pos)

        # Recreate the tracks
        track.PosTrack(tracker, tracked)
        track.PosTrack(tracker2, tracked)
        tracked.pos += (1,2,3)

        # Deactivate by the tracked
        track.deactivate(tracked=tracked)
        tracked.pos += (4,5,6)
        self.assertEquals((1,2,3), tracker.pos)
        self.assertEquals((2,3,4), tracker2.pos)
Exemplo n.º 2
0
    def test_deactivation(self):
        tracker = Object(pos=(3,4,5))
        tracked = Object()

        trk = track.PosTrack(tracker, tracked)
        trk.deactivate()
        tracked.pos = (1,4,6)

        self.assertEquals((1,4,6), tuple(tracked.pos))
        self.assertEquals((3,4,5), tuple(tracker.pos))
Exemplo n.º 3
0
    def test_tracked_independence(self):
        tracker = Object()
        tracked = Object()

        trk = track.PosTrack(tracker, tracked)
        self.assertEquals((0,0,0), tuple(tracked.pos))

        tracker.pos = (1,2,3)
        self.assertEquals((0,0,0), tuple(tracked.pos))
        self.assertEquals((1,2,3), tuple(tracker.pos))
Exemplo n.º 4
0
    def test_tracker_dependence(self):
        tracker = Object(pos=(3,4,5))
        self.assertEquals((3,4,5), tuple(tracker.pos))
        tracked = Object()

        trk = track.PosTrack(tracker, tracked)
        tracked.pos = (1,4,6)

        self.assertEquals((1,4,6), tuple(tracked.pos))
        self.assertEquals((4,8,11), tuple(tracker.pos))

        tracked.pos += (2,-3,1)

        self.assertEquals((3,1,7), tuple(tracked.pos))
        self.assertEquals((6,5,12), tuple(tracker.pos))

        tracked.pos += (0,0,0)

        self.assertEquals((3,1,7), tuple(tracked.pos))
        self.assertEquals((6,5,12), tuple(tracker.pos))