Ejemplo n.º 1
0
 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])])
Ejemplo n.º 2
0
 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})
Ejemplo n.º 3
0
 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])])
Ejemplo n.º 4
0
 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])])
Ejemplo n.º 5
0
 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))