|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2019 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2023 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
37 | 37 | import org.eclipse.swt.layout.FillLayout; |
38 | 38 | import org.eclipse.swt.layout.GridLayout; |
39 | 39 | import org.eclipse.swt.widgets.Button; |
| 40 | +import org.eclipse.swt.widgets.Composite; |
40 | 41 | import org.eclipse.swt.widgets.Display; |
41 | 42 | import org.eclipse.swt.widgets.Event; |
42 | 43 | import org.eclipse.swt.widgets.Shell; |
@@ -999,4 +1000,31 @@ public void test_Issue450_NoShellActivateOnSetFocus() { |
999 | 1000 | } |
1000 | 1001 | } |
1001 | 1002 | } |
| 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 | +} |
1002 | 1030 | } |
0 commit comments