Skip to content

Commit 49de167

Browse files
committed
Create small test case to illustrate #828
1 parent 17dcab0 commit 49de167

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2019 IBM Corporation and others.
2+
* Copyright (c) 2000, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -37,6 +37,7 @@
3737
import org.eclipse.swt.layout.FillLayout;
3838
import org.eclipse.swt.layout.GridLayout;
3939
import org.eclipse.swt.widgets.Button;
40+
import org.eclipse.swt.widgets.Composite;
4041
import org.eclipse.swt.widgets.Display;
4142
import org.eclipse.swt.widgets.Event;
4243
import org.eclipse.swt.widgets.Shell;
@@ -999,4 +1000,31 @@ public void test_Issue450_NoShellActivateOnSetFocus() {
9991000
}
10001001
}
10011002
}
1003+
1004+
@Test
1005+
public void test_Issue828_CheckShellBounds() {
1006+
Composite composite = new Composite(shell, SWT.NONE);
1007+
shell.setLayout(new FillLayout());
1008+
shell.setSize(400, 500);
1009+
shell.open();
1010+
1011+
// Shell should match the expected size of (400, 500)
1012+
Rectangle shellBounds = shell.getBounds();
1013+
assertEquals("shell width doesn't match expectation", shellBounds.width, 400);
1014+
assertEquals("shell height doesn't match expectation", shellBounds.height, 500);
1015+
1016+
Point shellSize = shell.getSize();
1017+
assertEquals("shell width doesn't match expectation", shellSize.x, 400);
1018+
assertEquals("shell height doesn't match expectation", shellSize.y, 500);
1019+
1020+
// Usable client area should be smaller (due to window decorations)
1021+
Rectangle shellClientArea = shell.getClientArea();
1022+
assertTrue("client area wider larger than expected", shellClientArea.width < 400);
1023+
assertTrue("client area higher larger than expected", shellClientArea.height < 500);
1024+
1025+
// The composite should take up the whole client area
1026+
Rectangle compositeBounds = composite.getBounds();
1027+
assertEquals("composite wider larger than expected", shellClientArea.width, compositeBounds.width);
1028+
assertEquals("composite higher larger than expected", shellClientArea.height, compositeBounds.height);
1029+
}
10021030
}

0 commit comments

Comments
 (0)