Skip to content

Commit 49924b8

Browse files
committed
Repair and execute disabled SWT tests
1 parent 359cb35 commit 49924b8

File tree

8 files changed

+60
-50
lines changed

8 files changed

+60
-50
lines changed

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011 Google, Inc.
2+
* Copyright (c) 2011, 2025 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -23,7 +23,6 @@
2323
import org.eclipse.wb.tests.designer.core.model.TestObjectInfo;
2424
import org.eclipse.wb.tests.designer.rcp.RcpModelTest;
2525

26-
import org.junit.jupiter.api.Disabled;
2726
import org.junit.jupiter.api.Test;
2827

2928
import java.util.ArrayList;
@@ -1043,13 +1042,13 @@ public void test_align_space_equally_2() throws Exception {
10431042
// Center in window
10441043
//
10451044
////////////////////////////////////////////////////////////////////////////
1046-
@Disabled
10471045
@Test
10481046
public void test_align_center_in_window() throws Exception {
10491047
CompositeInfo shell =
10501048
parseComposite(
10511049
"class Test extends Shell {",
10521050
" Test() {",
1051+
" super(SWT.NO_TRIM);",
10531052
" setSize(600, 400);",
10541053
" {",
10551054
" Button button = new Button(this, SWT.NONE);",
@@ -1073,10 +1072,11 @@ public void test_align_center_in_window() throws Exception {
10731072
assertEditor(
10741073
"class Test extends Shell {",
10751074
" Test() {",
1075+
" super(SWT.NO_TRIM);",
10761076
" setSize(600, 400);",
10771077
" {",
10781078
" Button button = new Button(this, SWT.NONE);",
1079-
" button.setBounds(262, 180, 60, 40);",
1079+
" button.setBounds(270, 180, 60, 40);",
10801080
" button.setText('000');",
10811081
" }",
10821082
" }",

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/menu/MenuItemTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2023 Google, Inc.
2+
* Copyright (c) 2011, 2025 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -32,7 +32,6 @@
3232
import static org.mockito.Mockito.verify;
3333
import static org.mockito.Mockito.verifyNoMoreInteractions;
3434

35-
import org.junit.jupiter.api.Disabled;
3635
import org.junit.jupiter.api.Test;
3736
import org.mockito.ArgumentMatchers;
3837

@@ -487,7 +486,6 @@ public void test_setStyle_fromCascade_toSeparator() throws Exception {
487486
/**
488487
* Test adding a selection listener to menu item.
489488
*/
490-
@Disabled
491489
@Test
492490
public void test_addSelectionListener() throws Exception {
493491
CompositeInfo shell =

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2024 Google, Inc. and others.
2+
* Copyright (c) 2011, 2025 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -17,20 +17,38 @@
1717
import org.eclipse.wb.internal.swt.model.property.editor.image.ImagePropertyEditor;
1818
import org.eclipse.wb.internal.swt.model.widgets.CompositeInfo;
1919
import org.eclipse.wb.tests.designer.rcp.RcpModelTest;
20+
import org.eclipse.wb.tests.designer.tests.Activator;
2021

22+
import org.eclipse.core.resources.IFile;
23+
import org.eclipse.core.runtime.Path;
2124
import org.eclipse.swt.SWT;
2225
import org.eclipse.swt.graphics.Image;
2326
import org.eclipse.swt.graphics.ImageData;
2427
import org.eclipse.swt.graphics.ImageLoader;
2528

29+
import org.junit.jupiter.api.BeforeEach;
30+
2631
import java.io.File;
32+
import java.io.InputStream;
2733

2834
/**
2935
* Tests for {@link ImagePropertyEditor}.
3036
*
3137
* @author lobas_av
3238
*/
3339
public abstract class ImagePropertyEditorTest extends RcpModelTest {
40+
41+
@Override
42+
@BeforeEach
43+
public void setUp() throws Exception {
44+
super.setUp();
45+
//
46+
IFile file = m_project.getFile(new Path("icons/test.png"));
47+
try (InputStream is = Activator.getFile("icons/test.png")) {
48+
setFileContent(file, is);
49+
}
50+
}
51+
3452
////////////////////////////////////////////////////////////////////////////
3553
//
3654
// Utils

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestNoManager.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2023 Google, Inc.
2+
* Copyright (c) 2011, 2025 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -22,7 +22,6 @@
2222

2323
import org.apache.commons.io.FilenameUtils;
2424
import org.junit.jupiter.api.BeforeEach;
25-
import org.junit.jupiter.api.Disabled;
2625
import org.junit.jupiter.api.Test;
2726

2827
import java.io.File;
@@ -97,24 +96,22 @@ public void test_textSource_absolutePath() throws Exception {
9796
/**
9897
* Image creation using constructor with input stream (over class resource).
9998
*/
100-
@Disabled
10199
@Test
102100
public void test_textSource_image_over_classpath() throws Exception {
103101
assert_getText_getClipboardSource_forSource(
104-
"new Image(null, getClass().getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))",
105-
"Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png",
106-
"new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))");
102+
"new Image(null, getClass().getResourceAsStream(\"/icons/test.png\"))",
103+
"Classpath: /icons/test.png",
104+
"new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/icons/test.png\"))");
107105
}
108106

109107
/**
110108
* Image creation using constructor with input stream (over class resource).
111109
*/
112-
@Disabled
113110
@Test
114111
public void test_textSource_image_over_classpath_OtherClass() throws Exception {
115112
assert_getText_getClipboardSource_forSource(
116-
"new Image(null, java.lang.String.class.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))",
117-
"Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png",
118-
"new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))");
113+
"new Image(null, java.lang.String.class.getResourceAsStream(\"/icons/test.png\"))",
114+
"Classpath: /icons/test.png",
115+
"new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/icons/test.png\"))");
119116
}
120117
}

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestWithManager.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2023 Google, Inc.
2+
* Copyright (c) 2011, 2025 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -26,7 +26,6 @@
2626

2727
import org.apache.commons.io.FilenameUtils;
2828
import org.junit.jupiter.api.BeforeEach;
29-
import org.junit.jupiter.api.Disabled;
3029
import org.junit.jupiter.api.Test;
3130

3231
import java.io.File;
@@ -103,25 +102,23 @@ public void test_textSource_absolutePath() throws Exception {
103102
/**
104103
* Image creation using constructor with input stream (over class resource).
105104
*/
106-
@Disabled
107105
@Test
108106
public void test_textSource_image_over_classpath() throws Exception {
109107
assert_getText_getClipboardSource_forSource(
110-
"new Image(null, getClass().getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))",
111-
"Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png",
112-
getInvocationSource(shell(), "{wbp_classTop}", "/javax/swing/plaf/basic/icons/JavaCup16.png"));
108+
"new Image(null, getClass().getResourceAsStream(\"/icons/test.png\"))",
109+
"Classpath: /icons/test.png",
110+
getInvocationSource(shell(), "{wbp_classTop}", "\"/icons/test.png\""));
113111
}
114112

115113
/**
116114
* Image creation using constructor with input stream (over class resource).
117115
*/
118-
@Disabled
119116
@Test
120117
public void test_textSource_image_over_classpath_OtherClass() throws Exception {
121118
assert_getText_getClipboardSource_forSource(
122-
"new Image(null, java.lang.String.class.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))",
123-
"Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png",
124-
getInvocationSource(shell(), "{wbp_classTop}", "/javax/swing/plaf/basic/icons/JavaCup16.png"));
119+
"new Image(null, java.lang.String.class.getResourceAsStream(\"/icons/test.png\"))",
120+
"Classpath: /icons/test.png",
121+
getInvocationSource(shell(), "{wbp_classTop}", "\"/icons/test.png\""));
125122
}
126123

127124
////////////////////////////////////////////////////////////////////////////
@@ -154,9 +151,9 @@ public void test_textSource_absolutePath2() throws Exception {
154151
public void test_textSource_image_over_classpath2() throws Exception {
155152
CompositeInfo shell = shell();
156153
assert_getText_getClipboardSource_forSource2(
157-
getInvocationSource(shell, "getClass()", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""),
158-
"Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png",
159-
getInvocationSource(shell, "{wbp_classTop}", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""));
154+
getInvocationSource(shell, "getClass()", "\"/icons/test.png\""),
155+
"Classpath: /icons/test.png",
156+
getInvocationSource(shell, "{wbp_classTop}", "\"/icons/test.png\""));
160157
}
161158

162159
/**
@@ -166,9 +163,9 @@ public void test_textSource_image_over_classpath2() throws Exception {
166163
public void test_textSource_image_over_classpath_OtherClass2() throws Exception {
167164
CompositeInfo shell = shell();
168165
assert_getText_getClipboardSource_forSource2(
169-
getInvocationSource(shell, "java.lang.String.class", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""),
170-
"Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png",
171-
getInvocationSource(shell, "{wbp_classTop}", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""));
166+
getInvocationSource(shell, "java.lang.String.class", "\"/icons/test.png\""),
167+
"Classpath: /icons/test.png",
168+
getInvocationSource(shell, "{wbp_classTop}", "\"/icons/test.png\""));
172169
}
173170

174171
/**
@@ -210,15 +207,15 @@ public void test_textSource_order() throws Exception {
210207
"}");
211208
ManagerContainerInfo.getResourceManagerInfo(shell);
212209
shell.addMethodInvocation("setImage(org.eclipse.swt.graphics.Image)",
213-
getInvocationSource(shell, "java.lang.String.class", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""));
210+
getInvocationSource(shell, "java.lang.String.class", "\"/icons/test.png\""));
214211
shell.refresh();
215212
assertEditor(
216213
"// filler filler filler",
217214
"public class Test extends Shell {",
218215
" private LocalResourceManager localResourceManager;",
219216
" public Test() {",
220217
" createResourceManager();",
221-
" setImage(localResourceManager.create(ImageDescriptor.createFromFile(String.class, \"/javax/swing/plaf/basic/icons/JavaCup16.png\")));",
218+
" setImage(localResourceManager.create(ImageDescriptor.createFromFile(String.class, \"/icons/test.png\")));",
222219
" }",
223220
" private void createResourceManager() {",
224221
" localResourceManager = new LocalResourceManager(JFaceResources.getResources(),this);",

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/SWTResourceManagerTest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@
1616
import org.eclipse.wb.internal.swt.model.widgets.CompositeInfo;
1717
import org.eclipse.wb.internal.swt.utils.ManagerUtils;
1818
import org.eclipse.wb.tests.designer.rcp.RcpModelTest;
19+
import org.eclipse.wb.tests.designer.tests.Activator;
1920

21+
import org.eclipse.core.resources.IFile;
22+
import org.eclipse.core.runtime.Path;
2023
import org.eclipse.swt.SWT;
2124
import org.eclipse.swt.graphics.Image;
2225
import org.eclipse.swt.graphics.ImageData;
2326

2427
import org.junit.jupiter.api.AfterEach;
2528
import org.junit.jupiter.api.BeforeEach;
26-
import org.junit.jupiter.api.Disabled;
2729
import org.junit.jupiter.api.Test;
2830

2931
import java.io.File;
32+
import java.io.InputStream;
3033
import java.lang.reflect.Array;
3134
import java.lang.reflect.Constructor;
3235

@@ -64,6 +67,11 @@ public void setUp() throws Exception {
6467
ImageClass = m_lastLoader.loadClass("org.eclipse.swt.graphics.Image");
6568
SWTManagerClass = m_lastLoader.loadClass("org.eclipse.wb.swt.SWTResourceManager");
6669
m_defaultDisplay = ReflectionUtils.invokeMethod(DisplayClass, "getDefault()");
70+
//
71+
IFile file = m_project.getFile(new Path("icons/test.png"));
72+
try (InputStream is = Activator.getFile("icons/test.png")) {
73+
setFileContent(file, is);
74+
}
6775
}
6876

6977
@Override
@@ -212,7 +220,6 @@ public void test_getImage_absolute() throws Exception {
212220
}
213221
}
214222

215-
@Disabled
216223
@Test
217224
public void test_getImage_classpath() throws Exception {
218225
// create image over SWTResourceManager
@@ -221,7 +228,7 @@ public void test_getImage_classpath() throws Exception {
221228
SWTManagerClass,
222229
"getImage(java.lang.Class,java.lang.String)",
223230
SWTManagerClass,
224-
"/javax/swing/plaf/basic/icons/JavaCup16.png");
231+
"/icons/test.png");
225232
// check create
226233
assertNotNull(image);
227234
// check state
@@ -230,10 +237,10 @@ public void test_getImage_classpath() throws Exception {
230237
SWTManagerClass,
231238
"getImage(java.lang.Class,java.lang.String)",
232239
SWTManagerClass,
233-
"/javax/swing/plaf/basic/icons/JavaCup16.png"));
240+
"/icons/test.png"));
234241
// load image directly over Image
235242
Image directImage = new Image(null,
236-
getClass().getResourceAsStream("/javax/swing/plaf/basic/icons/JavaCup16.png"));
243+
getClass().getResourceAsStream("/icons/test.png"));
237244
// check equals images
238245
try {
239246
assertEqualsImage(image, directImage);
@@ -294,7 +301,7 @@ public void test_disposeImages() throws Exception {
294301
SWTManagerClass,
295302
"getImage(java.lang.Class,java.lang.String)",
296303
SWTManagerClass,
297-
"/javax/swing/plaf/basic/icons/JavaCup16.png");
304+
"/icons/test.png");
298305
// check create
299306
assertNotNull(image);
300307
// check state

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.eclipse.swt.widgets.TableColumn;
3333
import org.eclipse.swt.widgets.TableItem;
3434

35-
import org.junit.jupiter.api.Disabled;
3635
import org.junit.jupiter.api.Test;
3736

3837
import java.util.List;
@@ -186,8 +185,6 @@ public void test_add_TableItem() throws Exception {
186185
* In SWT Cocoa and Linux GTK, the column headers are excluded from the client
187186
* area, hence why we have to adjust them for the tests.
188187
*/
189-
// Disabled because of https://github.com/eclipse-windowbuilder/windowbuilder/issues/389
190-
@Disabled
191188
@Test
192189
public void test_TableColumn() throws Exception {
193190
CompositeInfo shell =

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/CoordinateUtilsTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2024 Google, Inc. and others.
2+
* Copyright (c) 2011, 2025 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -28,7 +28,6 @@
2828
import org.eclipse.swt.widgets.Shell;
2929

3030
import org.assertj.core.api.Assertions;
31-
import org.junit.jupiter.api.Disabled;
3231
import org.junit.jupiter.api.Test;
3332

3433
/**
@@ -51,8 +50,6 @@ public void _test_exit() throws Exception {
5150
// Tests
5251
//
5352
////////////////////////////////////////////////////////////////////////////
54-
// Disabled because of https://github.com/eclipse-windowbuilder/windowbuilder/issues/389
55-
@Disabled
5653
@Test
5754
public void test_1() throws Exception {
5855
ShellInfo shell = (ShellInfo) parseComposite(
@@ -100,7 +97,6 @@ public void test_1() throws Exception {
10097
/**
10198
* Test for {@link CoordinateUtils#getClientAreaInsets2(Object)} for {@link Group}.
10299
*/
103-
@Disabled
104100
@Test
105101
public void test_withGroup() throws Exception {
106102
CompositeInfo shell =

0 commit comments

Comments
 (0)