aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/script
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/script')
-rw-r--r--tests/unit/script/htmlareaelement.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unit/script/htmlareaelement.rs b/tests/unit/script/htmlareaelement.rs
index be4cb12c0cc..becfd17b88a 100644
--- a/tests/unit/script/htmlareaelement.rs
+++ b/tests/unit/script/htmlareaelement.rs
@@ -187,4 +187,19 @@ fn test_hit_test_polygon() {
points: vec![7.0, 7.5, 8.2, 9.0, 11.0, 12.0],
};
assert!(!poly2.hit_test(&Point2D::new(10.0, 5.0)));
+ let poly3 = Area::Polygon {
+ points: vec![0.0, 0.0, 5.0, 0.0, 5.0, 5.0, 0.0, 5.0],
+ };
+ assert!(poly3.hit_test(&Point2D::new(1.0, 1.0)));
+ assert!(poly3.hit_test(&Point2D::new(2.0, 4.0)));
+ assert!(poly3.hit_test(&Point2D::new(4.0, 2.0)));
+ assert!(!poly3.hit_test(&Point2D::new(6.0, 0.0)));
+ assert!(!poly3.hit_test(&Point2D::new(0.0, 6.0)));
+ assert!(!poly3.hit_test(&Point2D::new(6.0, 6.0)));
+ // Concave polygon test
+ let poly4 = Area::Polygon {
+ points: vec![0.0, 0.0, 1.0, 1.0, 2.0, 0.0, 2.0, 2.0, 0.0, 2.0],
+ };
+ assert!(poly4.hit_test(&Point2D::new(1.5, 1.5)));
+ assert!(!poly4.hit_test(&Point2D::new(1.0, 0.0)));
}