Skip to content

Commit 0334215

Browse files
committed
Correct GC tests to properly execute at non-default device zoom
Some GC tests are explicitly executed on a non-default device zoom. However, most of them use a GC as subject to test that is created in a setup method that is thus using the original device zoom instead of the non-default one set by the test afterwards. This change ensures that when executing a test with a non-default device zoom, the GC used as subject to test is recreated to rely on that modified device zoom.
1 parent 5b42ae5 commit 0334215

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,13 +638,15 @@ public void test_setForegroundLorg_eclipse_swt_graphics_Color() {
638638
float[] dashes = new float[] { 1.2f, 3.3f };
639639
float dashOffset = 3.3f;
640640
float miterLimit = 2.6f;
641-
gc.setLineAttributes(new LineAttributes(width, cap, join, style, dashes, dashOffset, miterLimit));
641+
LineAttributes passedLineAttributes = new LineAttributes(width, cap, join, style, dashes, dashOffset, miterLimit);
642+
gc.setLineAttributes(passedLineAttributes);
642643
assertEquals("unexpected line width", width, gc.getLineWidth());
643644
assertEquals("unexpected line cap", cap, gc.getLineCap());
644645
assertEquals("unexpected line join", join, gc.getLineJoin());
645646
assertEquals("unexpected line style", style, gc.getLineStyle());
646647
assertEquals("actual line attributes differ from the ones that have been set",
647648
new LineAttributes(width, cap, join, style, dashes, dashOffset, miterLimit), gc.getLineAttributes());
649+
assertEquals("setter call changed line width", width, passedLineAttributes.width, 0.0f);
648650

649651
gc.setLineAttributes(new LineAttributes(1));
650652
assertEquals(new LineAttributes(1), gc.getLineAttributes());
@@ -853,7 +855,9 @@ RGB getRealRGB(Color color) {
853855

854856
private void executeWithNonDefaultDeviceZoom(Runnable executable) {
855857
int previousDeviceZoom = DPIUtil.getDeviceZoom();
856-
DPIUtil.setDeviceZoom(150);
858+
DPIUtil.setDeviceZoom(200);
859+
gc.dispose();
860+
gc = new GC(image);
857861
try {
858862
executable.run();
859863
} finally {

0 commit comments

Comments
 (0)