Пример #1
0
 def test_property(self):
     x = -200
     y = -100
     width = 600
     height = 300
     rect = DOMRect(x, y, width, height)
     self.assertFalse(rect.isempty())
     self.assertTrue(rect.isvalid())
     self.assertEqual(x, rect.x)
     self.assertEqual(x, rect.left)
     self.assertEqual(y, rect.y)
     self.assertEqual(y, rect.top)
     self.assertEqual(x + width, rect.right)
     self.assertEqual(y + height, rect.bottom)
     self.assertEqual(width, rect.width)
     self.assertEqual(height, rect.height)
     x = 100
     y = 200
     width = 300
     height = 600
     rect.x = x
     rect.y = y
     rect.width = width
     rect.height = height
     self.assertFalse(rect.isempty())
     self.assertTrue(rect.isvalid())
     self.assertEqual(x, rect.x)
     self.assertEqual(x, rect.left)
     self.assertEqual(y, rect.y)
     self.assertEqual(y, rect.top)
     self.assertEqual(x + width, rect.right)
     self.assertEqual(y + height, rect.bottom)
     self.assertEqual(width, rect.width)
     self.assertEqual(height, rect.height)
Пример #2
0
 def test_intersect02(self):
     a = DOMRect()
     b = DOMRect(30, 50, 100, 200)
     c = a.intersect(b)
     self.assertTrue(c.isempty())
     self.assertTrue(not c.isvalid())
     self.assertTrue(a.isempty())
     self.assertTrue(not a.isvalid())
     self.assertEqual((30, 50, 100, 200), (b.x, b.y, b.width, b.height))
Пример #3
0
 def test_united_valid_invalid(self):
     a = DOMRect(30, 50, 100, 200)
     b = DOMRect()
     c = a.unite(b.x, b.y, b.width, b.height)
     self.assertTrue(not c.isempty())
     self.assertTrue(c.isvalid())
     self.assertEqual((30, 50, 100, 200), (a.x, a.y, a.width, a.height))
     self.assertTrue(b.isempty())
     self.assertTrue(not b.isvalid())
Пример #4
0
 def test_intersect03(self):
     a = DOMRect(30, 50, 100, 200)
     b = DOMRect()
     c = a.intersect(b)
     self.assertTrue(not c.isempty())
     self.assertTrue(c.isvalid())
     self.assertEqual((30, 50, 100, 200), (c.x, c.y, c.width, c.height))
     self.assertEqual((30, 50, 100, 200), (a.x, a.y, a.width, a.height))
     self.assertTrue(b.isempty())
     self.assertTrue(not b.isvalid())