Skip to content

Commit 0f21a6e

Browse files
committed
Add details to test_LocationListener_ProgressListener_cancledLoad
Also, use String::isEmpty to check for the size of the location instead of its length
1 parent 3670670 commit 0f21a6e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,9 @@ public void test_LocationListener_ProgressListener_cancledLoad () {
683683
AtomicBoolean unexpectedLocationChanged = new AtomicBoolean(false);
684684
AtomicBoolean unexpectedProgressCompleted = new AtomicBoolean(false);
685685

686+
AtomicReference<String> unexpectedLocationChangedDetails = new AtomicReference<>("(empty)");
687+
AtomicReference<String> unexpectedProgressCompletedDetails = new AtomicReference<>("(empty)");
688+
686689
browser.addLocationListener(new LocationListener() {
687690
@Override
688691
public void changing(LocationEvent event) {
@@ -691,16 +694,19 @@ public void changing(LocationEvent event) {
691694
}
692695
@Override
693696
public void changed(LocationEvent event) {
694-
if (event.location.length() != 0) { // See footnote 1
697+
if (!event.location.isEmpty()) { // See footnote 1
695698
unexpectedLocationChanged.set(true);
699+
unexpectedLocationChangedDetails.set(event.location);
696700
}
697701
}
698702
});
699703

700704
browser.addProgressListener(completedAdapter(event -> {
701705
String location = browser.getUrl();
702-
if (location.length() != 0) { // See footnote 1
706+
if (!location.isEmpty()) { // See footnote 1
703707
unexpectedProgressCompleted.set(true);
708+
unexpectedProgressCompletedDetails.set(location);
709+
704710
}
705711
}));
706712
shell.open();
@@ -720,8 +726,8 @@ public void changed(LocationEvent event) {
720726
}
721727
String errMsg = "\nUnexpected event fired. \n"
722728
+ "LocationChanging (should be true): " + locationChanging.get() + "\n"
723-
+ "LocationChanged unexpectedly (should be false): " + unexpectedLocationChanged.get() + "\n"
724-
+ "ProgressChanged unexpectedly (should be false): " + unexpectedProgressCompleted.get() + "\n";
729+
+ "LocationChanged unexpectedly (should be false): " + unexpectedLocationChanged.get() + (unexpectedLocationChanged.get() ? " (" +unexpectedLocationChangedDetails.get() +")": "") + "\n"
730+
+ "ProgressChanged unexpectedly (should be false): " + unexpectedProgressCompleted.get() + (unexpectedProgressCompleted.get() ? " (" +unexpectedProgressCompletedDetails.get() +")": "")+ "\n";
725731

726732

727733
assertTrue(errMsg, passed);

0 commit comments

Comments
 (0)