Skip to content

Commit b68de5c

Browse files
committed
Reactivate TableTest.test_TableColumn
This test was seemingly disabled by accident.
1 parent ccda5c8 commit b68de5c

4 files changed

Lines changed: 54 additions & 12 deletions

File tree

org.eclipse.wb.os.linux/src/org/eclipse/wb/internal/os/linux/OSSupportLinux.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void beginShot(Control control) {
167167
_gtk_window_set_keep_above(getShellHandle(m_eclipseShell), true);
168168
}
169169
}
170-
shell.setLocation(10000, 10000);
170+
// shell.setLocation(10000, 10000);
171171
shell.setVisible(true);
172172
}
173173

@@ -313,7 +313,7 @@ private boolean bindImage(final Control control, final Image image) {
313313
public Image makeShot(Control control) throws Exception {
314314
Shell shell = getShell(control);
315315
// get the handle for the control
316-
shell.setLocation(10000, 10000);
316+
// shell.setLocation(10000, 10000);
317317
shell.setVisible(true);
318318
Rectangle controlBounds = control.getBounds();
319319
if (controlBounds.width == 0 || controlBounds.height == 0) {

org.eclipse.wb.os.linux/src_java24/org/eclipse/wb/internal/os/linux/OSSupportLinux.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void beginShot(Control control) {
8888
GTK3.gtk_window_set_keep_above(GtkWindow.from(m_eclipseShell), true);
8989
}
9090
}
91-
shell.setLocation(10000, 10000);
91+
// shell.setLocation(10000, 10000);
9292
shell.setVisible(true);
9393
}
9494

@@ -113,7 +113,7 @@ public void makeShots(Control control) throws Exception {
113113
@Override
114114
public Image makeShot(Control control) throws Exception {
115115
Shell shell = control.getShell();
116-
shell.setLocation(10000, 10000);
116+
// shell.setLocation(10000, 10000);
117117
shell.setVisible(true);
118118

119119
Rectangle controlBounds = control.getBounds();

org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/widgets/ShellInfo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.eclipse.wb.internal.core.model.description.ComponentDescription;
2121
import org.eclipse.wb.internal.core.model.util.ObjectInfoAction;
2222
import org.eclipse.wb.internal.core.utils.ast.AstEditor;
23-
import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils;
2423
import org.eclipse.wb.internal.swt.model.ModelMessages;
2524

2625
import org.eclipse.jdt.core.dom.MethodDeclaration;
@@ -64,7 +63,7 @@ public void setObject(Object object) throws Exception {
6463
// So, even through we don't open Shell, setRedraw(true) causes repaint for area under Shell.
6564
// So, we have to move Shell outside the view area ASAP.
6665
if (object != null) {
67-
ReflectionUtils.invokeMethod(object, "setLocation(int,int)", 10000, 10000);
66+
// ReflectionUtils.invokeMethod(object, "setLocation(int,int)", 10000, 10000);
6867
}
6968
}
7069

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/TableTest.java

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727

2828
import org.eclipse.draw2d.geometry.Insets;
2929
import org.eclipse.draw2d.geometry.Rectangle;
30+
import org.eclipse.swt.SWT;
31+
import org.eclipse.swt.layout.FillLayout;
32+
import org.eclipse.swt.widgets.Shell;
3033
import org.eclipse.swt.widgets.TabItem;
3134
import org.eclipse.swt.widgets.Table;
3235
import org.eclipse.swt.widgets.TableColumn;
3336
import org.eclipse.swt.widgets.TableItem;
3437

35-
import org.junit.jupiter.api.Disabled;
3638
import org.junit.jupiter.api.Test;
3739

3840
import java.util.List;
@@ -183,8 +185,6 @@ public Test() {
183185
* In SWT Cocoa and Linux GTK, the column headers are excluded from the client
184186
* area, hence why we have to adjust them for the tests.
185187
*/
186-
// Disabled because of https://github.com/eclipse-windowbuilder/windowbuilder/issues/389
187-
@Disabled
188188
@Test
189189
public void test_TableColumn() throws Exception {
190190
CompositeInfo shell = parseComposite("""
@@ -204,6 +204,45 @@ public Test() {
204204
}
205205
}""");
206206
shell.refresh();
207+
((Shell) shell.getWidget()).open();
208+
shell.getWidget().setVisible(true);
209+
shell.getWidget().setLocation(50, 0);
210+
waitEventLoop(5);
211+
shell.getWidget().setLocation(50, 0);
212+
waitEventLoop(5);
213+
shell.getWidget().setLocation(50, 0);
214+
waitEventLoop(5);
215+
shell.getWidget().setVisible(false);
216+
waitEventLoop(5);
217+
System.out.println(shell.getWidget().getBounds());
218+
{
219+
Shell s = new Shell() {
220+
{
221+
setLayout(new FillLayout());
222+
Table table = new Table(this, SWT.BORDER);
223+
table.setHeaderVisible(true);
224+
{
225+
TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);
226+
tableColumn_1.setWidth(50);
227+
}
228+
{
229+
TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);
230+
tableColumn_2.setWidth(100);
231+
}
232+
}
233+
234+
@Override
235+
protected void checkSubclass() {
236+
237+
}
238+
};
239+
s.open();
240+
Table t = (Table) s.getChildren()[0];
241+
TableColumn t0 = t.getColumn(0);
242+
System.out.println("<<<<");
243+
System.out.println(t0.getWidth());
244+
s.dispose();
245+
}
207246
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
208247
// prepare columns
209248
List<TableColumnInfo> columns = table.getColumns();
@@ -213,20 +252,24 @@ public Test() {
213252
// check bounds
214253
Insets tableInsets = table.getClientAreaInsets();
215254
{
255+
int headerHeight = table.getWidget().getHeaderHeight();
216256
// "model" bounds
217257
Rectangle modelBounds = column_1.getModelBounds();
258+
System.out.println("###############################");
259+
System.out.println(column_1.getWidget().getWidth());
260+
System.out.println(column_1.getModelBounds());
218261
if (!EnvironmentUtils.IS_WINDOWS) {
219-
modelBounds.y += table.getWidget().getHeaderHeight();
262+
modelBounds.y += headerHeight;
220263
}
221264
assertNotNull(modelBounds);
222265
assertEquals(0, modelBounds.x);
223266
assertEquals(0, modelBounds.y);
224267
assertEquals(50, modelBounds.width);
225-
assertTrue(modelBounds.height > 15 && modelBounds.height < 50);
268+
assertEquals(headerHeight, modelBounds.height);
226269
// "shot" bounds
227270
Rectangle bounds = column_1.getBounds();
228271
if (!EnvironmentUtils.IS_WINDOWS) {
229-
bounds.y += table.getWidget().getHeaderHeight();
272+
bounds.y += headerHeight;
230273
}
231274
assertEquals(tableInsets.left, bounds.x);
232275
assertEquals(tableInsets.top, bounds.y);

0 commit comments

Comments
 (0)