Example #1
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 #2
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 #3
0
 def test_largegap(self):
     layout = GridLayout(columns=2)
     layout.allocate(5, 1)
     assert layout.find() == (0, 0)
Example #4
0
 def test_largegap(self):
     layout = GridLayout(rows=2)
     layout.allocate(1, 5)
     assert layout.find() == (0, 0)
Example #5
0
 def test_gap(self):
     layout = GridLayout(columns=1)
     layout.allocate(1, 0)
     assert layout.find() == (0, 0)
Example #6
0
 def test_available_rowfixed(self):
     layout = GridLayout(rows=1)
     assert layout.available_positions() is not None
     layout.allocate(0, 0)
     assert layout.available_positions() is not None
     assert layout.available_positions() == (0, 1)
Example #7
0
 def test_gap(self):
     layout = GridLayout(rows=1)
     layout.allocate(0, 1)
     assert layout.find() == (0, 0)
Example #8
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 #9
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 #10
0
 def test_fit(self):
     layout = GridLayout(rows=2, columns=2)
     res = layout.find(rowspan=2, colspan=2)
     assert res == (0, 0)
Example #11
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 #12
0
 def test_allocate_colfixed(self):
     layout = GridLayout(columns=1)
     layout.allocate(0, 0)
     py.test.raises(LayoutException, layout.allocate, 0, 0)
Example #13
0
 def test_allocate_rowfixed(self):
     layout = GridLayout(rows=1)
     layout.allocate(0, 0)
     py.test.raises(LayoutException, layout.allocate, 0, 0)
Example #14
0
 def test_available_colfixed(self):
     layout = GridLayout(columns=1)
     assert layout.available_positions() is not None
     layout.allocate(0, 0)
     assert layout.available_positions() is not None
     assert layout.available_positions() == (1, 0)
Example #15
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 #16
0
 def test_allocate_refused_col(self):
     layout = GridLayout(rows=4, columns=4)
     layout.allocate(1, 0)
     # so far so good. Try to allocate something with a colspan of 2
     # at 0,0
     py.test.raises(LayoutException, layout.allocate, 0, 0, 2, 1)
Example #17
0
 def setup_method(self, method):
     self.layout = GridLayout(columns=7)
Example #18
0
 def test_available_fixed(self):
     layout = GridLayout(rows=1, columns=1)
     assert layout.available_positions() is not None
     layout.allocate(0, 0)
     assert layout.available_positions() is None