|
14 | 14 | package org.eclipse.swt.graphics;
|
15 | 15 |
|
16 | 16 | import static org.junit.Assert.assertEquals;
|
| 17 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 18 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
17 | 19 |
|
18 | 20 | import org.eclipse.swt.internal.*;
|
19 | 21 | import org.eclipse.swt.internal.win32.*;
|
@@ -55,4 +57,31 @@ public void testRegionMustBeScaledOnHandleOfScaledZoomLevel() {
|
55 | 57 | assertEquals("scaled region's y position should be double of unscaled region", bounds.y * scalingFactor, scaledBounds.y);
|
56 | 58 | }
|
57 | 59 |
|
| 60 | + |
| 61 | + @Test |
| 62 | + public void testRegionMustIntersectProperlyOn175Zoom() { |
| 63 | + Display display = Display.getDefault(); |
| 64 | + Shell shell = new Shell(display); |
| 65 | + DPITestUtil.changeDPIZoom(shell, 150); |
| 66 | + |
| 67 | + Region region = new Region(display); |
| 68 | + region.add(0, 0, 100, 51); |
| 69 | + boolean intersectWhenOverlapping = region.intersects(0, 50, 100, 50); |
| 70 | + assertTrue(intersectWhenOverlapping); |
| 71 | + |
| 72 | + region = new Region(display); |
| 73 | + region.add(0, 0, 100, 50); |
| 74 | + boolean dontIntersectWhenNotOverlapping = region.intersects(0, 50, 100, 50); |
| 75 | + assertFalse(dontIntersectWhenNotOverlapping); |
| 76 | + |
| 77 | + region = new Region(display); |
| 78 | + // 58 * 150 equals to 87 |
| 79 | + region.add(0, 58, 100, 20); |
| 80 | + // (27 + 31) should equal to 87, but will be 88 if 27 and 31 will |
| 81 | + // be rounded independently |
| 82 | + boolean shouldNotIntersect = region.intersects(0, 27, 100, 31); |
| 83 | + assertFalse(shouldNotIntersect); |
| 84 | + |
| 85 | + } |
| 86 | + |
58 | 87 | }
|
0 commit comments