コード例 #1
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_materialization(self):
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     virtual = block._virtualize()
     self.assertEqual(
         set(RecBlock._materialize_virtual_block(0, 0, virtual)),
         {(w, self.layout._get_item_position(w, False))
          for w in self.ws})
コード例 #2
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_subset_virtualization(self):
     block = RecBlock(self.layout, False, 2, 4, 6, 4)
     self.assertEqual(block._virtualize(),
                      [(self.ws[3], self.ws[3], self.ws[3], self.ws[3]),
                       (self.ws[3], self.ws[3], self.ws[3], self.ws[3]),
                       (self.ws[3], self.ws[3], self.ws[3], self.ws[3]),
                       (self.ws[3], self.ws[3], self.ws[3], self.ws[3]),
                       (self.ws[5], self.ws[5], self.ws[5], self.ws[5]),
                       (self.ws[5], self.ws[5], self.ws[5], self.ws[5])])
コード例 #3
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_non_rectangular_blocks(self):
     with self.assertRaises(NonRectangularRecBlockException):
         RecBlock(self.layout, False, 2, 0, 6, 8)
     with self.assertRaises(NonRectangularRecBlockException):
         RecBlock(self.layout, False, 0, 0, 3, 3)
     with self.assertRaises(NonRectangularRecBlockException):
         RecBlock(self.layout, False, 0, 2, 3, 6)
     with self.assertRaises(NonRectangularRecBlockException):
         RecBlock(self.layout, False, 2, 3, 4, 5)
コード例 #4
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_virtualization(self):
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     l = self.ws
     self.assertEqual(block._virtualize(),
                      [(l[0], l[0], l[1], l[1], l[1], l[1], l[1], l[1]),
                       (l[0], l[0], l[1], l[1], l[1], l[1], l[1], l[1]),
                       (l[0], l[0], l[2], None, l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[5], l[5], l[5], l[5]),
                       (l[4], l[4], l[4], l[4], l[5], l[5], l[5], l[5])])
コード例 #5
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_displaced_materialization(self):
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     virtual = block._virtualize()
     offset = (1, 2)
     expected = [(w, self.layout._get_item_position(w, False))
                 for w in self.ws]
     for i in range(0, len(expected)):
         widget, pos = expected[i]
         expected[i] = (widget, (pos[0] + offset[0], pos[1] + offset[1],
                                 pos[2], pos[3]))
     self.assertEqual(
         set(RecBlock._materialize_virtual_block(*offset, virtual)),
         set(expected))
コード例 #6
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_find(self):
     self.assertEqual(
         EmptyBlock.find_in_block(RecBlock(self.layout, False, 0, 0, 5, 5)),
         EmptyBlock(self.layout, False, 1, 1, 1, 3))
     self.assertEqual(
         EmptyBlock.find_in_block(Block(self.layout, False, 1, 1, 3, 2)),
         EmptyBlock(self.layout, False, 1, 1, 2, 2))
     self.assertEqual(
         EmptyBlock.find_in_block(Block(self.layout, False, 3, 1, 3, 3)),
         EmptyBlock(self.layout, False, 3, 1, 2, 1))
コード例 #7
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_no_suitable_block(self):
     layout = QTilingLayout(max_span=3)
     widgets = [Widget(0), Widget(1), Widget(2), Widget(3), Widget(4)]
     layout.addWidget(widgets[0], 0, 0, 2, 1)
     layout.addWidget(widgets[1], 0, 1, 1, 2)
     layout.addWidget(widgets[2], 1, 2, 2, 1)
     layout.addWidget(widgets[3], 2, 0, 1, 1)
     layout.addWidget(widgets[4], 2, 1, 1, 1)
     with self.assertRaises(ImpossibleToBuildBlockException):
         layout._fill_spaces(RecBlock(layout, False, 0, 0, 3, 3))
コード例 #8
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_left_space(self):
     layout = QTilingLayout(max_span=3)
     widgets = [Widget(0), Widget(1)]
     layout.addWidget(widgets[0], 0, 2, 1, 1)
     layout.addWidget(widgets[1], 2, 0, 1, 2)
     layout._drop_hanging_widgets(RecBlock(layout, False, 0, 0, 3, 3))
     self.assertEqual(layout._get_item_position(widgets[0], False),
                      (2, 2, 1, 1))
     self.assertEqual(layout._get_item_position(widgets[1], False),
                      (2, 0, 1, 2))
コード例 #9
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_right_block(self):
     layout = QTilingLayout(max_span=3)
     widgets = [Widget(0), Widget(1), Widget(2)]
     layout.addWidget(widgets[0], 0, 0, 2, 1)
     layout.addWidget(widgets[1], 0, 1, 1, 2)
     layout.addWidget(widgets[2], 1, 2, 1, 1)
     layout._fill_spaces(RecBlock(layout, False, 0, 0, 3, 3))
     self.assertEqual(layout._get_item_position(widgets[0], False),
                      (0, 0, 3, 1))
     self.assertEqual(layout._get_item_position(widgets[1], False),
                      (0, 1, 2, 2))
     self.assertEqual(layout._get_item_position(widgets[2], False),
                      (2, 1, 1, 2))
コード例 #10
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_displace_and_resize(self):
     l = self.ws
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     block.displace_and_resize(4, -4)
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     self.assertEqual(block._virtualize(),
                      [(None, None, None, None, None, None, None, None),
                       (None, None, None, None, None, None, None, None),
                       (None, None, None, None, None, None, None, None),
                       (None, None, None, None, None, None, None, None),
                       (l[0], l[0], l[1], l[1], l[1], l[1], l[1], l[1]),
                       (l[0], l[0], l[2], None, l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[5], l[5], l[5], l[5])])
     block.displace_and_resize(-2, 2)
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     self.assertEqual(block._virtualize(),
                      [(None, None, None, None, None, None, None, None),
                       (None, None, None, None, None, None, None, None),
                       (l[0], l[0], l[1], l[1], l[1], l[1], l[1], l[1]),
                       (l[0], l[0], l[1], l[1], l[1], l[1], l[1], l[1]),
                       (l[0], l[0], l[2], None, l[3], l[3], l[3], l[3]),
                       (l[0], l[0], l[2], None, l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[3], l[3], l[3], l[3]),
                       (l[4], l[4], l[4], l[4], l[5], l[5], l[5], l[5])])
コード例 #11
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_shrink_failure(self):
     block = RecBlock(self.layout, False, 0, 0, 8, 8)
     with self.assertRaises(SplitLimitException):
         block.displace_and_resize(0, -5)
コード例 #12
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_get_widgets(self):
     self.assertEqual(
         list(RecBlock(self.layout, False, 0, 0, 8, 8).get_widgets()),
         [(self.ws[0], (0, 0, 3, 2)), (self.ws[1], (0, 2, 2, 6)),
          (self.ws[2], (2, 2, 1, 1)), (self.ws[3], (2, 4, 4, 4)),
          (self.ws[4], (3, 0, 5, 4)), (self.ws[5], (6, 4, 2, 4))])
コード例 #13
0
ファイル: test.py プロジェクト: lufte/tiling-layout
 def test_valid_block(self):
     p = (0, 0, 8, 8)
     block = RecBlock(self.layout, False, *p)
     self.assertEqual((block.i, block.j, block.rowspan, block.colspan), p)