|
17 | 17 | import static org.hamcrest.Matchers.greaterThan; |
18 | 18 | import static org.junit.Assert.assertEquals; |
19 | 19 | import static org.junit.Assert.assertFalse; |
| 20 | +import static org.junit.Assert.assertNotEquals; |
20 | 21 |
|
21 | 22 | import java.util.List; |
22 | 23 |
|
|
31 | 32 | import org.eclipse.swt.graphics.Font; |
32 | 33 | import org.eclipse.swt.graphics.FontData; |
33 | 34 | import org.eclipse.swt.graphics.Point; |
| 35 | +import org.eclipse.swt.graphics.Rectangle; |
34 | 36 | import org.eclipse.swt.layout.FillLayout; |
35 | 37 | import org.eclipse.swt.widgets.Canvas; |
36 | 38 | import org.eclipse.swt.widgets.Composite; |
37 | 39 | import org.eclipse.swt.widgets.Control; |
38 | 40 | import org.eclipse.swt.widgets.Display; |
39 | 41 | import org.eclipse.swt.widgets.Event; |
40 | | -import org.eclipse.swt.widgets.ScrollBar; |
41 | 42 | import org.eclipse.swt.widgets.Shell; |
42 | 43 |
|
43 | 44 | import org.eclipse.jface.text.Document; |
@@ -176,18 +177,21 @@ public void testLayoutStickyLinesCanvasOnResize() { |
176 | 177 | stickyScrollingControl.setStickyLines(stickyLines); |
177 | 178 |
|
178 | 179 | Canvas stickyControlCanvas = getStickyControlCanvas(shell); |
179 | | - assertEquals(0, stickyControlCanvas.getBounds().x); |
180 | | - assertEquals(0, stickyControlCanvas.getBounds().y); |
181 | | - assertEquals(getExpectedWitdh(200), stickyControlCanvas.getBounds().width); |
182 | | - assertThat(stickyControlCanvas.getBounds().height, greaterThan(0)); |
| 180 | + Rectangle boundsBeforeResize = stickyControlCanvas.getBounds(); |
| 181 | + assertEquals(0, boundsBeforeResize.x); |
| 182 | + assertEquals(0, boundsBeforeResize.y); |
| 183 | + assertThat(boundsBeforeResize.width, greaterThan(0)); |
| 184 | + assertThat(boundsBeforeResize.height, greaterThan(0)); |
183 | 185 |
|
184 | 186 | sourceViewer.getTextWidget().setBounds(0, 0, 150, 200); |
185 | 187 |
|
186 | 188 | stickyControlCanvas = getStickyControlCanvas(shell); |
187 | | - assertEquals(0, stickyControlCanvas.getBounds().x); |
188 | | - assertEquals(0, stickyControlCanvas.getBounds().y); |
189 | | - assertEquals(getExpectedWitdh(150), stickyControlCanvas.getBounds().width); |
190 | | - assertThat(stickyControlCanvas.getBounds().height, greaterThan(0)); |
| 189 | + Rectangle boundsAfterResize = stickyControlCanvas.getBounds(); |
| 190 | + assertEquals(0, boundsAfterResize.x); |
| 191 | + assertEquals(0, boundsAfterResize.y); |
| 192 | + assertThat(boundsAfterResize.width, greaterThan(0)); |
| 193 | + assertNotEquals(boundsAfterResize.width, boundsBeforeResize.width); |
| 194 | + assertEquals(boundsAfterResize.height, boundsBeforeResize.height); |
191 | 195 | } |
192 | 196 |
|
193 | 197 | @Test |
@@ -268,13 +272,4 @@ private StyledText getStickyLineText() { |
268 | 272 | return (StyledText) canvas.getChildren()[1]; |
269 | 273 | } |
270 | 274 |
|
271 | | - private int getExpectedWitdh(int textWidgetWitdth) { |
272 | | - ScrollBar verticalBar = sourceViewer.getTextWidget().getVerticalBar(); |
273 | | - if (verticalBar.isVisible()) { |
274 | | - return textWidgetWitdth - verticalBar.getSize().x + 1; |
275 | | - } else { |
276 | | - return textWidgetWitdth + 1; |
277 | | - } |
278 | | - } |
279 | | - |
280 | 275 | } |
0 commit comments