Exemple #1
0
 def test_or(self):
     ax = 100
     ay = 100
     aw = 100
     ah = 200
     bx = 150
     by = 150
     bw = 50
     bh = 50
     cx = min(ax, bx)
     cy = min(ay, by)
     cw = max(ax + aw, bx + bw) - min(ax, bx)
     ch = max(ay + ah, by + bh) - min(ay, by)
     a = DOMRectReadOnly(ax, ay, aw, ah)
     b = DOMRectReadOnly(bx, by, bw, bh)
     c = a | b
     self.assertIsInstance(c, DOMRect)
     self.assertEqual(ax, a.x)
     self.assertEqual(ay, a.y)
     self.assertEqual(aw, a.width)
     self.assertEqual(ah, a.height)
     self.assertEqual(bx, b.x)
     self.assertEqual(by, b.y)
     self.assertEqual(bw, b.width)
     self.assertEqual(bh, b.height)
     self.assertEqual(cx, c.x)
     self.assertEqual(cy, c.y)
     self.assertEqual(cw, c.width)
     self.assertEqual(ch, c.height)
Exemple #2
0
 def test_and02(self):
     # left-upper
     w = 10
     h = 20
     xa = 100
     ya = 100
     xb = xa - w
     yb = ya - h / 2
     a = DOMRectReadOnly(xa, ya, w, h)
     b = DOMRectReadOnly(xb, yb, w, h)
     c = a & b
     self.assertIsInstance(c, DOMRect)
     self.assertEqual(xa, a.x)
     self.assertEqual(ya, a.y)
     self.assertEqual(w, a.width)
     self.assertEqual(h, a.height)
     self.assertEqual(xb, b.x)
     self.assertEqual(yb, b.y)
     self.assertEqual(w, b.width)
     self.assertEqual(h, b.height)
     expected_x = xa
     expected_y = ya
     expected_w = w
     expected_h = h
     self.assertEqual(expected_x, c.x, msg=(a, b, c))
     self.assertEqual(expected_y, c.y, msg=(a, b, c))
     self.assertEqual(expected_w, c.width, msg=(a, b, c))
     self.assertEqual(expected_h, c.height, msg=(a, b, c))
Exemple #3
0
 def test_and00(self):
     # valid rectangle AND invalid rectangle
     w = 10
     h = 20
     xa = 100
     ya = 100
     a = DOMRectReadOnly(xa, ya, w, h)
     b = DOMRectReadOnly()
     c = a & b
     self.assertIsInstance(c, DOMRect)
     self.assertEqual(xa, a.x)
     self.assertEqual(ya, a.y)
     self.assertEqual(w, a.width)
     self.assertEqual(h, a.height)
     self.assertIsNone(b.x)
     self.assertIsNone(b.y)
     self.assertEqual(0, b.width)
     self.assertEqual(0, b.height)
     expected_x = xa
     expected_y = ya
     expected_w = w
     expected_h = h
     self.assertEqual(expected_x, c.x, msg=(a, b, c))
     self.assertEqual(expected_y, c.y, msg=(a, b, c))
     self.assertEqual(expected_w, c.width, msg=(a, b, c))
     self.assertEqual(expected_h, c.height, msg=(a, b, c))
Exemple #4
0
    def test_read_only_ior(self):
        a = DOMRectReadOnly()
        b = DOMRectReadOnly()
        a |= b
        self.assertIsNone(a)

        a = DOMRectReadOnly()
        b = DOMRect()
        a |= b
        self.assertIsNone(a)
Exemple #5
0
 def test_iand(self):
     # a: (100, 100) - (200, 300)
     # b: (150, 150) - (200, 200)
     ax = 100
     ay = 100
     aw = 100
     ah = 200
     bx = 150
     by = 150
     bw = 50
     bh = 50
     cx = 150
     cy = 150
     cw = 50
     ch = 50
     a = DOMRect(ax, ay, aw, ah)
     b = DOMRectReadOnly(bx, by, bw, bh)
     a &= b
     self.assertIsInstance(a, DOMRect)
     self.assertEqual(cx, a.x)
     self.assertEqual(cy, a.y)
     self.assertEqual(cw, a.width)
     self.assertEqual(ch, a.height)
     self.assertEqual(bx, b.x)
     self.assertEqual(by, b.y)
     self.assertEqual(bw, b.width)
     self.assertEqual(bh, b.height)
Exemple #6
0
 def test_read_only_init01(self):
     width = 0
     height = 0
     rect = DOMRectReadOnly()
     self.assertTrue(rect.isempty())
     self.assertFalse(rect.isvalid())
     self.assertIsNone(rect.x)
     self.assertIsNone(rect.left)
     self.assertIsNone(rect.y)
     self.assertIsNone(rect.top)
     self.assertIsNone(rect.right)
     self.assertIsNone(rect.bottom)
     self.assertEqual(width, rect.width)
     self.assertEqual(height, rect.height)
Exemple #7
0
 def test_read_only_init03(self):
     x = -200
     y = -100
     width = 600
     height = 300
     rect = DOMRectReadOnly(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)