Example #1
0
 def test_blocks(self):
     layout = GridLayout(rows=4, columns=4)
     layout.allocate(0, 0, colspan=2, rowspan=2)
     res = layout.find(rowspan=2, colspan=2)
     assert res == (0, 2)
     layout.allocate(0, 2, colspan=2, rowspan=2)
     res = layout.find(rowspan=2, colspan=2)
     assert res == (2, 0)
     layout.allocate(2, 0, colspan=2, rowspan=2)
     res = layout.find(rowspan=2, colspan=2)
     assert res == (2, 2)
     layout.allocate(2, 2, colspan=2, rowspan=2)
     res = layout.find(rowspan=2, colspan=2)
     assert res == None
Example #2
0
class TestComplex1(object):
    """ Same as TestComplex but only columns fixed, rows grow """
    def setup_method(self, method):
        self.layout = GridLayout(columns=7)

    def test_blocks(self):
        self.layout.append(dummy, rowspan=3, colspan=3)
        self.layout.append(dummy, rowspan=2, colspan=2)
        self.layout.append(dummy, rowspan=2, colspan=2)
        self.layout.append(dummy, rowspan=3, colspan=2)
        self.layout.append(dummy, rowspan=3, colspan=2)
        self.layout.append(dummy, rowspan=2, colspan=3)
        assert self.layout.find() == (5, 0)

    def test_cells(self):
        for i in range(0, 5*7):
            self.layout.append(dummy)
        assert self.layout.find() == (5, 0)

    def test_widecells(self):
        for i in range(0, 5):
            self.layout.append(dummy, colspan=7)
        assert self.layout.find() == (5, 0)
Example #3
0
class TestFixedComplex1(object):
    """ a random, fixed layout """
    def setup_method(self, method):
        self.layout = GridLayout(rows=5, columns=7)

    def test_blocks(self):
        self.layout.append(dummy, rowspan=3, colspan=3)
        self.layout.append(dummy, rowspan=2, colspan=2)
        self.layout.append(dummy, rowspan=2, colspan=2)
        self.layout.append(dummy, rowspan=3, colspan=2)
        self.layout.append(dummy, rowspan=3, colspan=2)
        self.layout.append(dummy, rowspan=2, colspan=3)
        assert self.layout.find() is None

    def test_cells(self):
        for i in range(0, 5*7):
            self.layout.append(dummy)
        assert self.layout.find() is None

    def test_widecells(self):
        for i in range(0, 5):
            self.layout.append(dummy, colspan=7)
        assert self.layout.find() is None
Example #4
0
 def test_largegap(self):
     layout = GridLayout(columns=2)
     layout.allocate(5, 1)
     assert layout.find() == (0, 0)
Example #5
0
 def test_grow(self):
     layout = GridLayout(columns=2)
     layout.allocate(0, 0)
     assert layout.find() == (0, 1)
     layout.allocate(0, 1)
     assert layout.find() == (1, 0)
Example #6
0
 def test_gap(self):
     layout = GridLayout(columns=1)
     layout.allocate(1, 0)
     assert layout.find() == (0, 0)
Example #7
0
 def test_largegap(self):
     layout = GridLayout(rows=2)
     layout.allocate(1, 5)
     assert layout.find() == (0, 0)
Example #8
0
 def test_gap(self):
     layout = GridLayout(rows=1)
     layout.allocate(0, 1)
     assert layout.find() == (0, 0)
Example #9
0
 def test_notavailable(self):
     layout = GridLayout(rows=3, columns=3)
     layout.allocate(1,1)
     res = layout.find(rowspan=2, colspan=3)
     assert res is None
Example #10
0
 def test_available(self):
     layout = GridLayout(rows=3, columns=3)
     layout.allocate(0,0)
     res = layout.find(rowspan=2, colspan=3)
     assert res == (1, 0)
Example #11
0
 def test_fit(self):
     layout = GridLayout(rows=2, columns=2)
     res = layout.find(rowspan=2, colspan=2)
     assert res == (0, 0)