use of org.eclipse.swt.custom.LineBackgroundListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_custom_LineBackgroundListener method test_lineGetBackgroundLorg_eclipse_swt_custom_LineBackgroundEvent.
@Test
public void test_lineGetBackgroundLorg_eclipse_swt_custom_LineBackgroundEvent() {
LineBackgroundListener listener = event -> {
assertTrue(":1:", event.lineOffset == 0);
assertTrue(":2:", event.lineText.equals("0123456789"));
};
styledText.addLineBackgroundListener(listener);
styledText.setText("0123456789");
// force get line bg callback
styledText.selectAll();
styledText.copy();
styledText.removeLineBackgroundListener(listener);
}
use of org.eclipse.swt.custom.LineBackgroundListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_custom_StyledText method test_addLineBackgroundListenerLorg_eclipse_swt_custom_LineBackgroundListener.
@Test
public void test_addLineBackgroundListenerLorg_eclipse_swt_custom_LineBackgroundListener() {
String line = "Line1";
boolean exceptionThrown = false;
LineBackgroundListener listener = event -> listenerCalled = true;
try {
text.addLineBackgroundListener(null);
} catch (IllegalArgumentException e) {
exceptionThrown = true;
}
assertTrue("Expected exception not thrown", exceptionThrown);
listenerCalled = false;
text.setText(line);
text.addLineBackgroundListener(listener);
// cause StyledText to call the listener.
text.setSelection(0, text.getCharCount());
text.copy();
assertTrue("Listener not called", listenerCalled);
listenerCalled = false;
text.removeLineBackgroundListener(listener);
// cause StyledText to call the listener.
text.setText(line);
text.setSelection(0, text.getCharCount());
text.copy();
assertFalse("Listener not removed", listenerCalled);
}
Aggregations