Skip to content

Commit 169cbca

Browse files
committed
Sporadically failing Browser Tests logging #1466
This commit adds relevant loggings for debugging purposes to the Browser tests which sporadically fail for Edge Browser. contributes to #2098, #2113 and #2063
1 parent 9d3227d commit 169cbca

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,16 @@ public void test_LocationListener_changing() {
587587
@Test
588588
public void test_LocationListener_changed() {
589589
AtomicBoolean changedFired = new AtomicBoolean(false);
590-
browser.addLocationListener(changedAdapter(e -> changedFired.set(true)));
590+
browser.addLocationListener(changedAdapter(e -> {
591+
changedFired.set(true);
592+
}));
591593
shell.open();
592594
browser.setText("Hello world");
593595
boolean passed = waitForPassCondition(changedFired::get);
594-
assertTrue("LocationListener.changed() event was never fired", passed);
596+
String errorMsg = String.format(
597+
"LocationListener.changed() event was never fired. Browser URL after waitForPassCondition: %s",
598+
browser.getUrl());
599+
assertTrue(errorMsg, passed);
595600
}
596601
@Test
597602
public void test_LocationListener_changed_twoSetTextCycles() {
@@ -654,10 +659,12 @@ public void test_LocationListener_then_ProgressListener() {
654659
AtomicBoolean locationChanged = new AtomicBoolean(false);
655660
AtomicBoolean progressChanged = new AtomicBoolean(false);
656661
AtomicBoolean progressChangedAfterLocationChanged = new AtomicBoolean(false);
662+
AtomicReference<String> browserTextOnCompletedEvent = new AtomicReference<>();
657663

658664
browser.addLocationListener(changedAdapter(event -> locationChanged.set(true)));
659665

660666
browser.addProgressListener(completedAdapter(event -> {
667+
browserTextOnCompletedEvent.set(browser.getText());
661668
if (locationChanged.get()) {
662669
progressChangedAfterLocationChanged.set(true);
663670
}
@@ -671,8 +678,9 @@ public void test_LocationListener_then_ProgressListener() {
671678
String errorMsg = "\nUnexpected listener states. Expecting true for all, but have:\n"
672679
+ "Location changed: " + locationChanged.get() + "\n"
673680
+ "ProgressChangedAfterLocationChanged: " + progressChangedAfterLocationChanged.get() + "\n"
674-
+ "progressChanged: " + progressChanged.get();
675-
681+
+ "progressChanged: " + progressChanged.get()
682+
+ "browser text on completed event: " + browserTextOnCompletedEvent.get()
683+
+ "browser text after waitForPassCondition: " + browser.getText();
676684
assertTrue(errorMsg, progressChangedAfterLocationChanged.get());
677685
}
678686

@@ -986,6 +994,7 @@ public void completed(ProgressEvent event) {
986994
@Test
987995
public void test_ProgressListener_completed_Called() {
988996
AtomicBoolean childCompleted = new AtomicBoolean(false);
997+
AtomicReference<String> browserTextOnChangedEvent = new AtomicReference<>();
989998
ProgressListener l = new ProgressListener() {
990999

9911000
@Override
@@ -995,14 +1004,16 @@ public void completed(ProgressEvent event) {
9951004

9961005
@Override
9971006
public void changed(ProgressEvent event) {
998-
1007+
browserTextOnChangedEvent.set(browser.getText());
9991008
}
10001009
};
10011010
browser.addProgressListener(l);
10021011
browser.setText("<html><body>This test ensures that the completed listener is called.</body></html>");
10031012
shell.open();
10041013
boolean passed = waitForPassCondition(childCompleted::get);
1005-
assertTrue(passed);
1014+
String errorMsg = "Browser text before completed: " + browserTextOnChangedEvent.get() +
1015+
"\nBrowser text after completed: " + browser.getText();
1016+
assertTrue(errorMsg, passed);
10061017
}
10071018

10081019
@Test

0 commit comments

Comments
 (0)