|
14 | 14 | package org.eclipse.swt.tests.junit; |
15 | 15 |
|
16 | 16 |
|
| 17 | +import static org.eclipse.swt.tests.junit.SwtTestUtil.hasPixel; |
| 18 | +import static org.eclipse.swt.tests.junit.SwtTestUtil.openShell; |
| 19 | +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
17 | 20 | import static org.junit.jupiter.api.Assertions.assertEquals; |
18 | 21 | import static org.junit.jupiter.api.Assertions.assertFalse; |
19 | 22 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
20 | 23 | import static org.junit.jupiter.api.Assertions.assertNull; |
21 | 24 | import static org.junit.jupiter.api.Assertions.assertThrows; |
22 | | -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
23 | 25 | import static org.junit.jupiter.api.Assertions.assertTrue; |
24 | 26 | import static org.junit.jupiter.api.Assertions.fail; |
25 | 27 |
|
|
62 | 64 | import org.junit.jupiter.api.Disabled; |
63 | 65 | import org.junit.jupiter.api.Tag; |
64 | 66 | import org.junit.jupiter.api.Test; |
| 67 | +import org.junit.jupiter.params.ParameterizedTest; |
| 68 | +import org.junit.jupiter.params.provider.CsvSource; |
65 | 69 |
|
66 | 70 | /** |
67 | 71 | * Automated Test Suite for class org.eclipse.swt.custom.CTabFolder |
@@ -110,6 +114,8 @@ public void test_setFontLorg_eclipse_swt_graphics_Font() { |
110 | 114 |
|
111 | 115 | /* custom */ |
112 | 116 | protected CTabFolder ctabFolder; |
| 117 | +private static final Color RED = new Color(255, 0, 0); |
| 118 | +private static final Color BLUE = new Color(0, 0, 255); |
113 | 119 |
|
114 | 120 | /** |
115 | 121 | * Dispose all widgets in shell and create a new empty {@link CTabFolder}. |
@@ -1049,4 +1055,46 @@ public void test_dirtyIndicator_closesWhenCloseEnabled() { |
1049 | 1055 | } |
1050 | 1056 | } |
1051 | 1057 |
|
| 1058 | + |
| 1059 | +@ParameterizedTest |
| 1060 | +@CsvSource(value = {"false,1", "false,2", "true,1", "true,2"}) |
| 1061 | +public void test_tabsAreRendered(boolean nestComposite, int activateTab) { |
| 1062 | + Composite parent = shell; |
| 1063 | + Control[] children = shell.getChildren(); |
| 1064 | + for (Control child : children) { |
| 1065 | + child.dispose(); |
| 1066 | + } |
| 1067 | + if (nestComposite) { |
| 1068 | + parent = new Composite(parent, SWT.NONE); |
| 1069 | + parent.setLayout(new FillLayout()); |
| 1070 | + } |
| 1071 | + ctabFolder = new CTabFolder(parent, SWT.NONE); |
| 1072 | + setWidget(ctabFolder); |
| 1073 | + shell.setSize(800, 400); |
| 1074 | + ctabFolder.setBackground(RED); |
| 1075 | + ctabFolder.setForeground(BLUE); |
| 1076 | + ctabFolder.setSelectionForeground(BLUE); |
| 1077 | + CTabItem tab = createTabItem(1); |
| 1078 | + openShell(shell); |
| 1079 | + processEvents(); |
| 1080 | + Rectangle bounds = tab.getBounds(); |
| 1081 | + assertTrue(hasPixel(ctabFolder, BLUE, bounds)); |
| 1082 | + tab = createTabItem(2); |
| 1083 | + ctabFolder.setSelection(activateTab); |
| 1084 | + SwtTestUtil.processEvents(); |
| 1085 | + bounds = tab.getBounds(); |
| 1086 | + assertTrue(hasPixel(ctabFolder, BLUE, bounds)); |
| 1087 | + tab.dispose(); |
| 1088 | + SwtTestUtil.processEvents(); |
| 1089 | + assertFalse(hasPixel(ctabFolder, BLUE, bounds)); |
| 1090 | +} |
| 1091 | + |
| 1092 | +private CTabItem createTabItem(int i) { |
| 1093 | + CTabItem item = new CTabItem(ctabFolder, SWT.CLOSE); |
| 1094 | + item.setText("█".repeat(10)); |
| 1095 | + Label content = new Label(ctabFolder, SWT.NONE); |
| 1096 | + content.setText("Content " + i); |
| 1097 | + item.setControl(content); |
| 1098 | + return item; |
| 1099 | +} |
1052 | 1100 | } |
0 commit comments