Skip to content

Commit 209925b

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

5 files changed

Lines changed: 39 additions & 13 deletions

File tree

org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/eval/evaluators/InvocationEvaluator.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.eclipse.jdt.core.dom.TagElement;
4343
import org.eclipse.jdt.core.dom.TextElement;
4444
import org.eclipse.jdt.core.dom.ThisExpression;
45+
import org.eclipse.swt.widgets.TableColumn;
4546

4647
import net.bytebuddy.ByteBuddy;
4748
import net.bytebuddy.TypeCache;
@@ -56,6 +57,7 @@
5657
import java.lang.reflect.InvocationTargetException;
5758
import java.lang.reflect.Method;
5859
import java.util.List;
60+
import java.util.Objects;
5961

6062
/**
6163
* Implementation of {@link IExpressionEvaluator} for {@link MethodInvocation}.
@@ -116,8 +118,19 @@ private Object evaluate(EvaluationContext context, MethodInvocation invocation)
116118
expressionValue != null,
117119
ICoreExceptionConstants.EVAL_NULL_INVOCATION_EXPRESSION,
118120
context.getSource(invocation));
121+
if ("tableColumn_1.setWidth(50)".equals(invocation.toString())) {
122+
System.out.println(">>> " + Objects.toIdentityString(expressionValue) + ", "
123+
+ ((TableColumn) expressionValue).getWidth());
124+
}
119125
// invoke method
120-
return invokeMethod(context, expressionValue, null, invocation, methodBinding);
126+
try {
127+
return invokeMethod(context, expressionValue, null, invocation, methodBinding);
128+
} finally {
129+
if ("tableColumn_1.setWidth(50)".equals(invocation.toString())) {
130+
System.out.println("<<< " + Objects.toIdentityString(expressionValue) + ", "
131+
+ ((TableColumn) expressionValue).getWidth());
132+
}
133+
}
121134
}
122135
}
123136

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: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@
2727

2828
import org.eclipse.draw2d.geometry.Insets;
2929
import org.eclipse.draw2d.geometry.Rectangle;
30+
import org.eclipse.swt.widgets.Shell;
3031
import org.eclipse.swt.widgets.TabItem;
3132
import org.eclipse.swt.widgets.Table;
3233
import org.eclipse.swt.widgets.TableColumn;
3334
import org.eclipse.swt.widgets.TableItem;
3435

35-
import org.junit.jupiter.api.Disabled;
3636
import org.junit.jupiter.api.Test;
3737

3838
import java.util.List;
39+
import java.util.Objects;
3940

4041
/**
4142
* Tests for {@link TableInfo}, {@link TableColumnInfo} and {@link TableItemInfo}.
@@ -183,8 +184,6 @@ public Test() {
183184
* In SWT Cocoa and Linux GTK, the column headers are excluded from the client
184185
* area, hence why we have to adjust them for the tests.
185186
*/
186-
// Disabled because of https://github.com/eclipse-windowbuilder/windowbuilder/issues/389
187-
@Disabled
188187
@Test
189188
public void test_TableColumn() throws Exception {
190189
CompositeInfo shell = parseComposite("""
@@ -204,6 +203,17 @@ public Test() {
204203
}
205204
}""");
206205
shell.refresh();
206+
((Shell) shell.getWidget()).open();
207+
shell.getWidget().setVisible(true);
208+
shell.getWidget().setLocation(50, 0);
209+
waitEventLoop(5);
210+
shell.getWidget().setLocation(50, 0);
211+
waitEventLoop(5);
212+
shell.getWidget().setLocation(50, 0);
213+
waitEventLoop(5);
214+
shell.getWidget().setVisible(false);
215+
waitEventLoop(5);
216+
System.out.println(shell.getWidget().getBounds());
207217
TableInfo table = (TableInfo) shell.getChildrenControls().get(0);
208218
// prepare columns
209219
List<TableColumnInfo> columns = table.getColumns();
@@ -213,20 +223,24 @@ public Test() {
213223
// check bounds
214224
Insets tableInsets = table.getClientAreaInsets();
215225
{
226+
int headerHeight = table.getWidget().getHeaderHeight();
216227
// "model" bounds
217228
Rectangle modelBounds = column_1.getModelBounds();
229+
System.out.println("###############################");
230+
System.out.println(Objects.toIdentityString(column_1.getWidget()) + ", " + column_1.getWidget().getWidth());
231+
System.out.println(column_1.getModelBounds());
218232
if (!EnvironmentUtils.IS_WINDOWS) {
219-
modelBounds.y += table.getWidget().getHeaderHeight();
233+
modelBounds.y += headerHeight;
220234
}
221235
assertNotNull(modelBounds);
222236
assertEquals(0, modelBounds.x);
223237
assertEquals(0, modelBounds.y);
224238
assertEquals(50, modelBounds.width);
225-
assertTrue(modelBounds.height > 15 && modelBounds.height < 50);
239+
assertEquals(headerHeight, modelBounds.height);
226240
// "shot" bounds
227241
Rectangle bounds = column_1.getBounds();
228242
if (!EnvironmentUtils.IS_WINDOWS) {
229-
bounds.y += table.getWidget().getHeaderHeight();
243+
bounds.y += headerHeight;
230244
}
231245
assertEquals(tableInsets.left, bounds.x);
232246
assertEquals(tableInsets.top, bounds.y);

0 commit comments

Comments
 (0)