Skip to content

Commit 9bb106c

Browse files
committed
Use a common font for FormLayout tests
The system font is not consistent between the operating systems. As a result, the expected font sizes might differ between Linux, Windows and MacOS.
1 parent 331b232 commit 9bb106c

6 files changed

Lines changed: 46 additions & 82 deletions

File tree

org.eclipse.wb.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ Export-Package: org.eclipse.wb.tests.designer;x-internal:=true,
149149
org.eclipse.wb.tests.utils;x-internal:=true
150150
Import-Package: com.jgoodies.forms.factories;version="[1.9.0,2.0.0]",
151151
com.jgoodies.forms.layout;version="[1.9.0,2.0.0]",
152+
com.jgoodies.forms.util;version="[1.9.0,2.0.0)",
152153
net.miginfocom.layout;version="[11.3.0,12.0.0]",
153154
net.miginfocom.swing;version="[11.3.0,12.0.0]",
154155
org.apache.commons.collections4;version="[4.4.0,5.0.0)",

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/AbstractFormLayoutTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2024 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
@@ -17,22 +17,42 @@
1717
import org.eclipse.wb.tests.designer.swing.model.layout.AbstractLayoutTest;
1818

1919
import com.jgoodies.forms.layout.FormLayout;
20+
import com.jgoodies.forms.util.DefaultUnitConverter;
2021

22+
import org.junit.jupiter.api.AfterAll;
23+
import org.junit.jupiter.api.BeforeAll;
2124
import org.junit.jupiter.api.BeforeEach;
2225

26+
import java.awt.Font;
27+
2328
/**
2429
* Abstract test for {@link FormLayout}.
2530
*
2631
* @author scheglov_ke
2732
*/
2833
public abstract class AbstractFormLayoutTest extends AbstractLayoutTest {
34+
private static Font m_font;
2935
protected boolean m_useFormsImports = true;
3036

3137
////////////////////////////////////////////////////////////////////////////
3238
//
3339
// Life cycle
3440
//
3541
////////////////////////////////////////////////////////////////////////////
42+
43+
@BeforeAll
44+
public static void setUpAll() {
45+
m_font = DefaultUnitConverter.getInstance().getDefaultDialogFont();
46+
Font newFont = new Font(Font.MONOSPACED, Font.PLAIN, 12);
47+
DefaultUnitConverter.getInstance().setDefaultDialogFont(newFont);
48+
}
49+
50+
@AfterAll
51+
public static void tearDownAll() {
52+
DefaultUnitConverter.getInstance().setDefaultDialogFont(m_font);
53+
m_font = null;
54+
}
55+
3656
@Override
3757
@BeforeEach
3858
public void setUp() throws Exception {

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/DefaultComponentFactoryTest.java

Lines changed: 1 addition & 3 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
@@ -29,7 +29,6 @@
2929
import com.jgoodies.forms.factories.DefaultComponentFactory;
3030

3131
import org.assertj.core.api.Assertions;
32-
import org.junit.jupiter.api.Disabled;
3332
import org.junit.jupiter.api.Test;
3433

3534
/**
@@ -109,7 +108,6 @@ public void test_createLabel() throws Exception {
109108
* Test for {@link DefaultComponentFactoryCreateLabelEntryInfo}.
110109
*/
111110
@DisposeProjectAfter
112-
@Disabled
113111
@Test
114112
public void test_createLabel_tool() throws Exception {
115113
do_projectDispose();

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormDimensionInfoTest.java

Lines changed: 1 addition & 4 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
import com.jgoodies.forms.layout.Size;
2727
import com.jgoodies.forms.layout.Sizes;
2828

29-
import org.junit.jupiter.api.Disabled;
3029
import org.junit.jupiter.api.Test;
3130

3231
import java.lang.reflect.Method;
@@ -266,7 +265,6 @@ public void test_rowTemplates() throws Exception {
266265
// Convert to GAP template
267266
//
268267
////////////////////////////////////////////////////////////////////////////
269-
@Disabled
270268
@Test
271269
public void test_convertToNearestGap_columns() throws Exception {
272270
check_convertToNearestGap_column("4px", 5, "LABEL_COMPONENT_GAP_COLSPEC");
@@ -284,7 +282,6 @@ public void test_convertToNearestGap_columns() throws Exception {
284282
check_convertToNearestGap_column("20px", 5, null);
285283
}
286284

287-
@Disabled
288285
@Test
289286
public void test_convertToNearestGap_rows() throws Exception {
290287
check_convertToNearestGap_row("4px", 5, "LABEL_COMPONENT_GAP_ROWSPEC");

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormLayoutConverterTest.java

Lines changed: 8 additions & 12 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
@@ -18,7 +18,6 @@
1818

1919
import com.jgoodies.forms.layout.FormLayout;
2020

21-
import org.junit.jupiter.api.Disabled;
2221
import org.junit.jupiter.api.Test;
2322

2423
/**
@@ -60,7 +59,6 @@ public void test_empty() throws Exception {
6059
"}");
6160
}
6261

63-
@Disabled
6462
@Test
6563
public void test_oneRow() throws Exception {
6664
ContainerInfo panel =
@@ -96,7 +94,7 @@ public void test_oneRow() throws Exception {
9694
" setLayout(new FormLayout(new ColumnSpec[] {",
9795
" FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,",
9896
" ColumnSpec.decode('100px'),",
99-
" ColumnSpec.decode('16px'),",
97+
" FormSpecs.UNRELATED_GAP_COLSPEC,",
10098
" ColumnSpec.decode('80px'),},",
10199
" new RowSpec[] {",
102100
" FormSpecs.UNRELATED_GAP_ROWSPEC,",
@@ -118,7 +116,6 @@ public void test_oneRow() throws Exception {
118116
}
119117
}
120118

121-
@Disabled
122119
@Test
123120
public void test_twoRows_spanColumns() throws Exception {
124121
ContainerInfo panel =
@@ -181,7 +178,6 @@ public void test_twoRows_spanColumns() throws Exception {
181178
"}");
182179
}
183180

184-
@Disabled
185181
@Test
186182
public void test_Switching_fromGridBagLayout() throws Exception {
187183
ContainerInfo panel =
@@ -243,17 +239,17 @@ public void test_Switching_fromGridBagLayout() throws Exception {
243239
"public class Test extends JPanel {",
244240
" public Test() {",
245241
" setLayout(new FormLayout(new ColumnSpec[] {",
246-
" ColumnSpec.decode('46px'),",
242+
" ColumnSpec.decode('60px'),",
247243
" FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,",
248-
" ColumnSpec.decode('305px'),",
244+
" ColumnSpec.decode('275px'),",
249245
" FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,",
250-
" ColumnSpec.decode('89px'),},",
246+
" ColumnSpec.decode('105px'),},",
251247
" new RowSpec[] {",
252-
" RowSpec.decode('20px'),",
248+
" RowSpec.decode('26px'),",
253249
" FormSpecs.LINE_GAP_ROWSPEC,",
254-
" RowSpec.decode('20px'),",
250+
" RowSpec.decode('21px'),",
255251
" FormSpecs.LINE_GAP_ROWSPEC,",
256-
" RowSpec.decode('23px'),}));",
252+
" RowSpec.decode('27px'),}));",
257253
" {",
258254
" JComboBox comboBox = new JComboBox();",
259255
" add(comboBox, '3, 1, fill, center');",

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/model/layout/FormLayout/FormSizeInfoTest.java

Lines changed: 14 additions & 62 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
@@ -15,9 +15,6 @@
1515
import org.eclipse.wb.internal.swing.FormLayout.model.FormSizeConstantInfo;
1616
import org.eclipse.wb.internal.swing.FormLayout.model.FormSizeInfo;
1717
import org.eclipse.wb.internal.swing.laf.LafSupport;
18-
import org.eclipse.wb.tests.designer.Expectations;
19-
import org.eclipse.wb.tests.designer.Expectations.DblValue;
20-
import org.eclipse.wb.tests.designer.Expectations.IntValue;
2118

2219
import com.jgoodies.forms.layout.ColumnSpec;
2320
import com.jgoodies.forms.layout.ConstantSize;
@@ -26,7 +23,6 @@
2623
import com.jgoodies.forms.layout.Sizes;
2724

2825
import org.junit.jupiter.api.BeforeEach;
29-
import org.junit.jupiter.api.Disabled;
3026
import org.junit.jupiter.api.Test;
3127

3228
/**
@@ -64,7 +60,6 @@ public void _test_exit() throws Exception {
6460
/**
6561
* Test for {@link FormSizeConstantInfo}.
6662
*/
67-
@Disabled
6863
@Test
6964
public void test_FormSizeConstantInfo() throws Exception {
7065
FormSizeConstantInfo size = new FormSizeConstantInfo(25, ConstantSize.PIXEL);
@@ -110,12 +105,7 @@ public void test_FormSizeConstantInfo() throws Exception {
110105
assertEquals(40, size.getValue(), 0.001);
111106
// to millimeters
112107
size.setUnit(ConstantSize.MILLIMETER);
113-
assertEquals(
114-
Expectations.get(10.7, new DblValue[]{
115-
new DblValue("kosta-home", 8.5),
116-
new DblValue("scheglov-win", 10.7)}),
117-
size.getValue(),
118-
0.001);
108+
assertEquals(10.7, size.getValue(), 0.001);
119109
}
120110
}
121111

@@ -139,53 +129,34 @@ public void test_FormSizeConstantInfo_convertSpecial() throws Exception {
139129
/**
140130
* Test for {@link FormSizeConstantInfo#convertFromPixels(int, Unit)}
141131
*/
142-
@Disabled
143132
@Test
144133
public void test_FormSizeConstantInfo_convertFromPixels() throws Exception {
145134
{
146135
double expected = 50.0;
147136
check_convertFromPixels(50, ConstantSize.PIXEL, expected);
148137
}
149138
{
150-
double expected =
151-
Expectations.get(39.0, new DblValue[]{
152-
new DblValue("kosta-home", 31.0),
153-
new DblValue("scheglov-win", 38.0)});
139+
double expected = 38;
154140
check_convertFromPixels(50, ConstantSize.POINT, expected);
155141
}
156142
{
157-
double expected =
158-
Expectations.get(34.0, new DblValue[]{
159-
new DblValue("kosta-home", 26.0),
160-
new DblValue("scheglov-win", 34.0)});
143+
double expected = 29;
161144
check_convertFromPixels(50, ConstantSize.DIALOG_UNITS_X, expected);
162145
}
163146
{
164-
double expected =
165-
Expectations.get(34.0, new DblValue[]{
166-
new DblValue("kosta-home", 32.0),
167-
new DblValue("scheglov-win", 34.0)});
147+
double expected = 32;
168148
check_convertFromPixels(50, ConstantSize.DIALOG_UNITS_Y, expected);
169149
}
170150
{
171-
double expected =
172-
Expectations.get(13.4, new DblValue[]{
173-
new DblValue("kosta-home", 10.7),
174-
new DblValue("scheglov-win", 13.4)});
151+
double expected = 13.4;
175152
check_convertFromPixels(50, ConstantSize.MILLIMETER, expected);
176153
}
177154
{
178-
double expected =
179-
Expectations.get(1.3, new DblValue[]{
180-
new DblValue("kosta-home", 1.1),
181-
new DblValue("scheglov-win", 1.3)});
155+
double expected = 1.3;
182156
check_convertFromPixels(50, ConstantSize.CENTIMETER, expected);
183157
}
184158
{
185-
double expected =
186-
Expectations.get(0.5, new DblValue[]{
187-
new DblValue("kosta-home", 0.4),
188-
new DblValue("scheglov-win", 0.5)});
159+
double expected = 0.5;
189160
check_convertFromPixels(50, ConstantSize.INCH, expected);
190161
}
191162
}
@@ -197,53 +168,34 @@ private void check_convertFromPixels(int pixels, Unit unit, double expected) thr
197168
/**
198169
* Test for {@link FormSizeConstantInfo#convertToPixels(double, Unit)}
199170
*/
200-
@Disabled
201171
@Test
202172
public void test_FormSizeConstantInfo_convertToPixels() throws Exception {
203173
{
204174
int expected = 10;
205175
check_convertToPixels(10.0, ConstantSize.PIXEL, expected);
206176
}
207177
{
208-
int expected =
209-
Expectations.get(13, new IntValue[]{
210-
new IntValue("kosta-home", 16),
211-
new IntValue("scheglov-win", 13)});
178+
int expected = 13;
212179
check_convertToPixels(10.0, ConstantSize.POINT, expected);
213180
}
214181
{
215-
int expected =
216-
Expectations.get(15, new IntValue[]{
217-
new IntValue("kosta-home", 20),
218-
new IntValue("scheglov-win", 15)});
182+
int expected = 18;
219183
check_convertToPixels(10.0, ConstantSize.DIALOG_UNITS_X, expected);
220184
}
221185
{
222-
int expected =
223-
Expectations.get(15, new IntValue[]{
224-
new IntValue("kosta-home", 16),
225-
new IntValue("scheglov-win", 15)});
186+
int expected = 16;
226187
check_convertToPixels(10.0, ConstantSize.DIALOG_UNITS_Y, expected);
227188
}
228189
{
229-
int expected =
230-
Expectations.get(38, new IntValue[]{
231-
new IntValue("kosta-home", 47),
232-
new IntValue("scheglov-win", 38)});
190+
int expected = 38;
233191
check_convertToPixels(10.0, ConstantSize.MILLIMETER, expected);
234192
}
235193
{
236-
int expected =
237-
Expectations.get(378, new IntValue[]{
238-
new IntValue("kosta-home", 472),
239-
new IntValue("scheglov-win", 378)});
194+
int expected = 378;
240195
check_convertToPixels(10.0, ConstantSize.CENTIMETER, expected);
241196
}
242197
{
243-
int expected =
244-
Expectations.get(960, new IntValue[]{
245-
new IntValue("kosta-home", 1200),
246-
new IntValue("scheglov-win", 960)});
198+
int expected = 960;
247199
check_convertToPixels(10.0, ConstantSize.INCH, expected);
248200
}
249201
}

0 commit comments

Comments
 (0)