Skip to content

Commit 82aeac5

Browse files
committed
Corrected TextLayout to produce right number of lines when '\r\n'
sequence comes. Incorporated new failing and passing junits. Fixes #184
1 parent 04d6864 commit 82aeac5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_TextLayout.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,4 +1273,33 @@ public void test_Bug579335_win32_StyledText_LongLine() {
12731273
font.dispose();
12741274
}
12751275
}
1276+
@Test
1277+
public void test_getLineCount() {
1278+
//Skipping this test for GTK and Cocoa as this pr #1320 applies only for windows platform.
1279+
//Without pr #1320(master) : Number of lines: 11 (for Cocoa it is : 10)
1280+
//Without pr #1320(master) : Bounds of the text layout: Rectangle {0, 0, 30, 220} (for Cocoa it is : {0, 0, 27, 176})
1281+
//Expected : Number of lines: 7 (for Cocoa it is : 10)
1282+
//Expected : Bounds of the text layout: Rectangle {0, 0, 43, 140} (for Cocoa it is : {0, 0, 27, 176})
1283+
if (SwtTestUtil.isGTK || SwtTestUtil.isCocoa) {
1284+
//TODO Fix not applicable for GTK and Cocoa.
1285+
if (SwtTestUtil.verbose) {
1286+
System.out.println("Excluded test_getLineCount(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_TextLayout)");
1287+
}
1288+
return;
1289+
}
1290+
1291+
TextLayout layout = new TextLayout(display);
1292+
try {
1293+
String text = "\rabc\ndef\r\rghi\n\njkl\r\nmno\r\n\r\npqr\r";
1294+
layout.setText(text);
1295+
int lineCount = layout.getLineCount();
1296+
assertEquals(7, lineCount);
1297+
1298+
Rectangle bounds = layout.getBounds();
1299+
assertEquals(43, bounds.width);
1300+
assertEquals(140, bounds.height);
1301+
} finally {
1302+
layout.dispose();
1303+
}
1304+
}
12761305
}

0 commit comments

Comments
 (0)