Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,9 +14,9 @@
*******************************************************************************/
package org.eclipse.swt.tests.junit;


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -49,7 +49,6 @@ public void tearDown() {
shell.dispose();
}
private void testListener(final int[] segments, boolean exceptionExpected) {
boolean exceptionThrown = false;
BidiSegmentListener listener = event -> {
assertEquals(0, event.lineOffset, " incorrect BidiSegmentEvent");
assertEquals(line, event.lineText, " incorrect BidiSegmentEvent");
Expand All @@ -60,26 +59,26 @@ private void testListener(final int[] segments, boolean exceptionExpected) {

listenerCalled = false;
try {
text.addBidiSegmentListener(listener);
text.getLocationAtOffset(0);
} catch (IllegalArgumentException e) {
exceptionThrown = true;
if (exceptionExpected) {
assertThrows(IllegalArgumentException.class, () -> {
text.addBidiSegmentListener(listener);
text.getLocationAtOffset(0);
});
} else {
text.addBidiSegmentListener(listener);
text.getLocationAtOffset(0);
}

} finally {
text.removeBidiSegmentListener(listener);
}
if (exceptionExpected) {
assertTrue(exceptionThrown, " expected exception not thrown");
} else {
assertFalse(exceptionThrown, " unexpected exception thrown");
}
if (SwtTestUtil.isBidi()) {
assertTrue(listenerCalled, " listener not called");
} else {
assertFalse(listenerCalled, " listener called when it shouldn't be");
}
}
private void testStyleRangeSegmenting(final int[] segments, int[] boldRanges) {
boolean exceptionThrown = false;
BidiSegmentListener listener = event -> {
assertEquals(0, event.lineOffset, " incorrect BidiSegmentEvent");
assertEquals(line, event.lineText, " incorrect BidiSegmentEvent");
Expand All @@ -97,12 +96,9 @@ private void testStyleRangeSegmenting(final int[] segments, int[] boldRanges) {
text.setStyleRange(styleRange);
}
text.getLocationAtOffset(0);
} catch (IllegalArgumentException e) {
exceptionThrown = true;
} finally {
text.removeBidiSegmentListener(listener);
}
assertFalse(exceptionThrown, " unexpected exception thrown");
if (SwtTestUtil.isBidi()) {
assertTrue(listenerCalled, " listener not called");
} else {
Expand Down
Loading