Skip to content

Commit

Permalink
Corrected TextLayout to produce right number of lines when '\r\n'
Browse files Browse the repository at this point in the history
sequence comes. Incorporated new failing and passing junits.

Fixes #184
  • Loading branch information
deepika-u committed Dec 12, 2024
1 parent cc7e708 commit c8072a6
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1273,4 +1273,33 @@ public void test_Bug579335_win32_StyledText_LongLine() {
font.dispose();
}
}
@Test
public void test_getLineCount() {
//Skipping this test for GTK and Cocoa as this pr #1320 applies only for windows platform.
//Without pr #1320(master) : Number of lines: 11 (for Cocoa it is : 10)
//Without pr #1320(master) : Bounds of the text layout: Rectangle {0, 0, 30, 220} (for Cocoa it is : {0, 0, 27, 176})
//Expected : Number of lines: 7 (for Cocoa it is : 10)
//Expected : Bounds of the text layout: Rectangle {0, 0, 43, 140} (for Cocoa it is : {0, 0, 27, 176})
if (SwtTestUtil.isGTK || SwtTestUtil.isCocoa) {
//TODO Fix not applicable for GTK and Cocoa.
if (SwtTestUtil.verbose) {
System.out.println("Excluded test_getLineCount(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_TextLayout)");
}
return;
}

TextLayout layout = new TextLayout(display);
try {
String text = "\rabc\ndef\r\rghi\n\njkl\r\nmno\r\n\r\npqr\r";
layout.setText(text);
int lineCount = layout.getLineCount();
assertEquals(7, lineCount);

Rectangle bounds = layout.getBounds();
assertEquals(43, bounds.width);
assertEquals(140, bounds.height);
} finally {
layout.dispose();
}
}
}

0 comments on commit c8072a6

Please sign in to comment.