Exemplo n.º 1
0
    def test_one_source_active(self):
        fs = FrameSorter(self.frames_callback, [1, 2])

        fs.add(1, 0, 'a')
        fs.add(1, 1, 'a')
        fs.add(1, 2, 'a')

        self.assertEquals(self.frames, [])

        fs.flush()

        self.assertEquals(self.frames, [(0, 1, 'a'),
                                        (1, 1, 'a'),
                                        (2, 1, 'a')])
Exemplo n.º 2
0
    def test_not_sorted_input(self):
        fs = FrameSorter(self.frames_callback, [1, 2])

        fs.add(1, 0, 'a')
        fs.add(2, 1, 'b')
        fs.add(1, 5, 'a')
        fs.add(2, 2, 'b')
        fs.add(1, 10, 'a')
        fs.add(2, 3, 'b')

        self.assertEquals(self.frames, [(0, 1, 'a'),
                                        (1, 2, 'b'),
                                        (2, 2, 'b'),
                                        (3, 2, 'b')])
        self.clear()

        fs.add(2, 4, 'b')
        fs.add(2, 6, 'b')

        self.assertEquals(self.frames, [(4, 2, 'b'),
                                        (5, 1, 'a'),
                                        (6, 2, 'b')])
        self.clear()

        fs.add(1, 15, 'a')

        self.assertEquals(self.frames, [])

        fs.add(2, 7, 'b')
        fs.add(1, 20, 'a')
        fs.add(2, 16, 'b')


        self.assertEquals(self.frames, [(7, 2, 'b'),
                                        (10, 1, 'a'),
                                        (15, 1, 'a'),
                                        (16, 2, 'b')])
        self.clear()

        fs.flush()

        self.assertEquals(self.frames, [(20, 1, 'a')])
Exemplo n.º 3
0
    def test_add_flush_add(self):
        fs = FrameSorter(self.frames_callback, [1, 2])

        fs.add(1, 0, 'a')
        fs.add(2, 1, 'b')
        fs.add(1, 2, 'a')

        self.assertEquals(self.frames, [(0, 1, 'a'),
                                        (1, 2, 'b')])
        self.clear()

        fs.flush()

        self.assertEquals(self.frames, [(2, 1, 'a')])
        self.clear()

        fs.add(2, 3, 'b')
        fs.add(1, 4, 'a')
        fs.add(2, 5, 'b')

        self.assertEquals(self.frames, [(3, 2, 'b'),
                                        (4, 1, 'a')])
        self.clear()

        fs.flush()

        self.assertEquals(self.frames, [(5, 2, 'b')])
Exemplo n.º 4
0
    def test_sorted_input(self):
        fs = FrameSorter(self.frames_callback, [1, 2])

        fs.add(1, 0, 'a')
        fs.add(2, 1, 'b')
        fs.add(1, 2, 'a')
        fs.add(2, 3, 'b')
        fs.add(1, 4, 'a')
        fs.add(2, 5, 'b')

        self.assertEquals(self.frames, [(0, 1, 'a'),
                                        (1, 2, 'b'),
                                        (2, 1, 'a'),
                                        (3, 2, 'b'),
                                        (4, 1, 'a')])
        self.clear()

        fs.add(2, 6, 'b')
        fs.add(2, 7, 'b')

        self.assertEquals(self.frames, [])

        fs.add(1, 8, 'a')

        self.assertEquals(self.frames, [(5, 2, 'b'),
                                        (6, 2, 'b'),
                                        (7, 2, 'b')])
        self.clear()

        fs.add(2, 9, 'b')
        fs.add(1, 10, 'a')
        fs.add(2, 11, 'b')


        self.assertEquals(self.frames, [(8, 1, 'a'),
                                        (9, 2, 'b'),
                                        (10, 1, 'a')])
        self.clear()

        fs.flush()

        self.assertEquals(self.frames, [(11, 2, 'b')])