Exemplo n.º 1
0
    def test_from_image(self):
        s = SwirlFrame()
        s.from_image(self.swirl_1_img)

        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=0xff, x4=0), s.rows[0])
        assert_equal(SwirlFrameRow(x1=0xfe, x2=0xff, x3=0xff, x4=0), s.rows[1])
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=0xfe, x4=0xff), s.rows[2])
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=3, x4=4), s.rows[3])
        assert_equal(SwirlFrameRow(x1=0xff, x2=0, x3=0xff, x4=0), s.rows[4])
Exemplo n.º 2
0
    def test_from_block(self):
        block = Block()
        block.from_list([1, 2, 4, 5, 6])
        s = SwirlFrameRow()

        s.from_block(block, 0, False)
        assert_equal(SwirlFrameRow(x1=1, x2=2, x3=4, x4=5), s)

        s.from_block(block, 3, True)
        assert_equal(SwirlFrameRow(x1=5, x2=6, x3=0xff, x4=0), s)
Exemplo n.º 3
0
    def test_from_block_repeating_not_mode_01(self):
        s = SwirlFrame()
        block = Block()
        block.from_list([0, 0x7e, 0, 50, 120, 126, 98, 0, 0xff, 0xff, 0, 0])
        s.from_block(block, 0)

        assert_equal(len(s.rows), 224)
        for row in s.rows[0:0x7e]:
            assert_equal(SwirlFrameRow(x1=0, x2=50, x3=120, x4=126), row)
        for row in s.rows[0x7e:]:
            assert_equal(SwirlFrameRow(x1=0, x2=0xff, x3=0xff, x4=0), row)
Exemplo n.º 4
0
    def test_from_block_repeating_mode_01(self):
        s = SwirlFrame()
        block = Block()
        block.from_list([1, 0x7f, 1, 2, 97, 3, 4, 0])
        s.from_block(block, 0)

        assert_equal(len(s.rows), 224)
        for row in s.rows[0:0x7f]:
            assert_equal(SwirlFrameRow(x1=1, x2=2, x3=0xff, x4=0), row)
        for row in s.rows[0x7f:]:
            assert_equal(SwirlFrameRow(x1=3, x2=4, x3=0xff, x4=0), row)
Exemplo n.º 5
0
    def test_from_block_continuous_mode_01(self):
        s = SwirlFrame()
        block = Block()
        block.from_list([1, 0x7f, 1, 2, 0x82, 50, 51, 52, 53, 95, 3, 4, 0])
        s.from_block(block, 0)

        assert_equal(len(s.rows), 224)
        for row in s.rows[0:0x7f]:
            assert_equal(SwirlFrameRow(x1=1, x2=2, x3=0xff, x4=0), row)
        assert_equal(SwirlFrameRow(x1=50, x2=51, x3=0xff, x4=0), s.rows[0x7f])
        assert_equal(SwirlFrameRow(x1=52, x2=53, x3=0xff, x4=0), s.rows[0x80])
        for row in s.rows[0x81:]:
            assert_equal(SwirlFrameRow(x1=3, x2=4, x3=0xff, x4=0), row)
Exemplo n.º 6
0
    def test_from_block_continuous_not_mode_01(self):
        s = SwirlFrame()
        block = Block()
        block.from_list([
            0, 0x7f, 0, 50, 120, 126, 0x82, 50, 51, 52, 53, 54, 55, 0xff, 0,
            95, 0, 0xff, 0xff, 0, 0
        ])
        s.from_block(block, 0)

        assert_equal(len(s.rows), 224)
        for row in s.rows[0:0x7f]:
            assert_equal(SwirlFrameRow(x1=0, x2=50, x3=120, x4=126), row)
        assert_equal(SwirlFrameRow(x1=50, x2=51, x3=52, x4=53), s.rows[0x7f])
        assert_equal(SwirlFrameRow(x1=54, x2=55, x3=0xff, x4=0), s.rows[0x80])
        for row in s.rows[0x81:]:
            assert_equal(SwirlFrameRow(x1=0, x2=0xff, x3=0xff, x4=0), row)
Exemplo n.º 7
0
    def test_from_block(self):
        block = Block()
        block.from_list([1, 2, 4, 5, 6])
        s = SwirlFrameRow()

        s.from_block(block, 0, False)
        assert_equal(SwirlFrameRow(x1=1, x2=2, x3=4, x4=5), s)

        s.from_block(block, 3, True)
        assert_equal(SwirlFrameRow(x1=5, x2=6, x3=0xff, x4=0), s)
Exemplo n.º 8
0
    def test_to_block(self):
        block = Block()

        s = SwirlFrameRow(x1=3, x2=5, x3=55, x4=92)
        block.from_list([33, 33, 33, 33, 33])
        s.to_block(block, 1, False)
        assert_equal([33, 3, 5, 55, 92], block.to_list())

        s = SwirlFrameRow(x1=3, x2=5, x3=0xff, x4=0)
        block.from_list([33, 33, 33, 33, 33])
        s.to_block(block, 2, True)
        assert_equal([33, 33, 3, 5, 33], block.to_list())
Exemplo n.º 9
0
    def test_to_block(self):
        block = Block()

        s = SwirlFrameRow(x1=3, x2=5, x3=55, x4=92)
        block.from_list([33, 33, 33, 33, 33])
        s.to_block(block, 1, False)
        assert_equal([33, 3, 5, 55, 92], block.to_list())

        s = SwirlFrameRow(x1=3, x2=5, x3=0xff, x4=0)
        block.from_list([33, 33, 33, 33, 33])
        s.to_block(block, 2, True)
        assert_equal([33, 33, 3, 5, 33], block.to_list())
Exemplo n.º 10
0
    def test_from_image_data(self):
        image_data = self.swirl_1_img.load()
        s = SwirlFrameRow()

        s.from_image_data(image_data=image_data, y=0)
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=0xff, x4=0), s)

        s.from_image_data(image_data=image_data, y=1)
        assert_equal(SwirlFrameRow(x1=0xfe, x2=0xff, x3=0xff, x4=0), s)

        s.from_image_data(image_data=image_data, y=2)
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=0xfe, x4=0xff), s)

        s.from_image_data(image_data=image_data, y=3)
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=3, x4=4), s)

        s.from_image_data(image_data=image_data, y=4)
        assert_equal(SwirlFrameRow(x1=0xff, x2=0, x3=0xff, x4=0), s)
Exemplo n.º 11
0
    def test_from_image_data(self):
        image_data = self.swirl_1_img.load()
        s = SwirlFrameRow()

        s.from_image_data(image_data=image_data, y=0)
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=0xff, x4=0), s)

        s.from_image_data(image_data=image_data, y=1)
        assert_equal(SwirlFrameRow(x1=0xfe, x2=0xff, x3=0xff, x4=0), s)

        s.from_image_data(image_data=image_data, y=2)
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=0xfe, x4=0xff), s)

        s.from_image_data(image_data=image_data, y=3)
        assert_equal(SwirlFrameRow(x1=0, x2=1, x3=3, x4=4), s)

        s.from_image_data(image_data=image_data, y=4)
        assert_equal(SwirlFrameRow(x1=0xff, x2=0, x3=0xff, x4=0), s)