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())
def test_unite_point12(self): # right-lower w = 10 h = 20 xa = 100 ya = 100 xb = xa + w + w / 2 yb = ya + h + h / 2 a = DOMRect(xa, ya, w, h) c = a.unite(xb, yb) expected_x = xa expected_y = ya expected_w = w + w / 2 expected_h = h + h / 2 self.assertEqual(expected_x, c.x, msg=(a, c)) self.assertEqual(expected_y, c.y, msg=(a, c)) self.assertEqual(expected_w, c.width, msg=(a, c)) self.assertEqual(expected_h, c.height, msg=(a, c))
def test_unite_point03(self): # upper-right w = 10 h = 20 xa = 100 ya = 100 xb = xa + w yb = ya - h / 2 a = DOMRect(xa, ya, w, h) c = a.unite(xb, yb) expected_x = xa expected_y = yb expected_w = w expected_h = h + h / 2 self.assertEqual(expected_x, c.x, msg=(a, c)) self.assertEqual(expected_y, c.y, msg=(a, c)) self.assertEqual(expected_w, c.width, msg=(a, c)) self.assertEqual(expected_h, c.height, msg=(a, c))
def test_unite_point01(self): # left-upper w = 10 h = 20 xa = 100 ya = 100 xb = xa - w / 2 yb = ya - h / 2 a = DOMRect(xa, ya, w, h) c = a.unite(xb, yb) expected_x = xb expected_y = yb expected_w = w + w / 2 expected_h = h + h / 2 self.assertEqual(expected_x, c.x, msg=(a, c)) self.assertEqual(expected_y, c.y, msg=(a, c)) self.assertEqual(expected_w, c.width, msg=(a, c)) self.assertEqual(expected_h, c.height, msg=(a, c))
def test_united_invalid_invalid(self): a = DOMRect() b = DOMRect() c = a.unite(b.x, b.y, b.width, b.height) self.assertTrue(c.isempty()) self.assertTrue(not c.isvalid())