Esempio n. 1
0
 def testShrinkHomogeneousSecondary(self):
     """VBoxLayout.allocateSize shrink homogeneous secondary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((100, 200), requested_size)
     allocated_size.width = 5
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(5, 40))
     self.assertEqual(self.widget2.allocated_size.size, Size(5, 40))
     self.assertEqual(self.widget3.allocated_size.size, Size(5, 40))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(100, 200))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(100, 247))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(100, 294))
Esempio n. 2
0
 def testShrinkTotallyHomogeneousPrimary(self):
     """VBoxLayout.allocateSize shrink totally homogeneous primary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((100, 200), requested_size)
     allocated_size.height = 0
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(15, 0))
     self.assertEqual(self.widget2.allocated_size.size, Size(15, 0))
     self.assertEqual(self.widget3.allocated_size.size, Size(15, 0))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(100, 200))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(100, 200))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(100, 200))
Esempio n. 3
0
 def testShrinkHomogeneousSecondary(self):
     """HBoxLayout.allocateSize shrink homogeneous secondary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((200, 100), requested_size)
     allocated_size.height = 5
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(40, 5))
     self.assertEqual(self.widget2.allocated_size.size, Size(40, 5))
     self.assertEqual(self.widget3.allocated_size.size, Size(40, 5))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(200, 100))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(247, 100))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(294, 100))
Esempio n. 4
0
    def testShrinkTotallyHeterogeneousPrimary(self):
        """HBoxLayout.allocateSize shrink totally heterogeneous primary works.

        """
        requested_size = self.hetero_box.requestSize(self.children)
        allocated_size = SizeAllocation((200, 100), requested_size)
        allocated_size.width = 0
        self.hetero_box.allocateSize(allocated_size, requested_size,
                                     self.children)
        self.assertEqual(self.widget1.allocated_size.size, Size(0, 15))
        self.assertEqual(self.widget2.allocated_size.size, Size(0, 15))
        self.assertEqual(self.widget3.allocated_size.size, Size(0, 15))
        self.assertEqual(self.widget1.allocated_size.pos, Pos(200, 100))
        self.assertEqual(self.widget2.allocated_size.pos, Pos(200, 100))
        self.assertEqual(self.widget3.allocated_size.pos, Pos(200, 100))
Esempio n. 5
0
 def testShrinkALotHomogeneousPrimary(self):
     """VBoxLayout.allocateSize shrink a lot homogeneous primary works."""
     requested_size = self.homo_box.requestSize(self.children)
     allocated_size = SizeAllocation((100, 200), requested_size)
     allocated_size.height = 10
     # 10 is not even enough to hold the spacing.  The children should have
     # a width of 0. Now we have to shrink the spacing.  Its length is 7.
     # There are two spacings: 7, 7 for a total of 14.  We apply a homothecy
     # to make it fit into 10. 7 * 10 / 14 = 5. 14*10/14=10. So we get 5 and
     # 10 for coords out of the homothecy, and therefore 5 and 5 for the
     # lengths of the spacing.  We don't care about the lengths but we are
     # interested in the coords since they give us the positions of our
     # children.  Just add a 0 in front of the list:  0, 5, 10.
     self.homo_box.allocateSize(allocated_size, requested_size,
                                self.children)
     self.assertEqual(self.widget1.allocated_size.size, Size(15, 0))
     self.assertEqual(self.widget2.allocated_size.size, Size(15, 0))
     self.assertEqual(self.widget3.allocated_size.size, Size(15, 0))
     self.assertEqual(self.widget1.allocated_size.pos, Pos(100, 200))
     self.assertEqual(self.widget2.allocated_size.pos, Pos(100, 205))
     self.assertEqual(self.widget3.allocated_size.pos, Pos(100, 210))