From 1a03198f6f71c5ead4f35169c69412db3fc844e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Fri, 13 Dec 2024 13:02:16 +0200 Subject: [PATCH] Convert Browser test strings to test blocks It's really cumbersome to edit them while experimenting thus converting. --- .../Test_org_eclipse_swt_browser_Browser.java | 209 ++++++++++-------- 1 file changed, 119 insertions(+), 90 deletions(-) diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java index 323651c7380..7ed5d135d21 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -803,8 +803,10 @@ public void test_OpenWindowListener_openHasValidEventDetails() { }); shell.open(); - browser.setText("\n" + - "This test uses Javascript to open a new window."); + browser.setText(""" + + This test uses Javascript to open a new window. + """); boolean passed = waitForPassCondition(openFiredCorrectly::get); assertTrue("Test timed out. OpenWindow event not fired.", passed); @@ -833,15 +835,17 @@ public void test_OpenWindowListener_open_ChildPopup() { shell.open(); - browser.setText("" - + "\n" + - "This test uses javascript to open a new window."); + browser.setText(""" + + + This test uses javascript to open a new window. + """); boolean passed = waitForPassCondition(childCompleted::get); - String errMsg = "\nTest timed out."; + String errMsg = "Test timed out."; assertTrue(errMsg, passed); } @@ -880,11 +884,13 @@ public void test_OpenWindow_Progress_Listener_ValidateEventOrder() { shell.open(); - browser.setText("" - + "\n" + - "This test uses javascript to open a new window."); + browser.setText(""" + + + This test uses javascript to open a new window. + """); boolean passed = waitForPassCondition(() -> windowOpenFired.get() && visibilityShowed.get() && childCompleted.get()); @@ -1323,12 +1329,14 @@ public void completed(ProgressEvent event) { }); shell.open(); - browser.setText("" - + "\n" + - "This test uses javascript to open a new window."); + browser.setText(""" + \ + + This test uses javascript to open a new window. + """); boolean passed = waitForPassCondition(secondChildCompleted::get); @@ -1365,11 +1373,13 @@ public void test_VisibilityWindowListener_eventSize() { })); shell.open(); - browser.setText("" - + "\n" + - "This test uses javascript to open a new window."); + browser.setText(""" + + + This test uses javascript to open a new window. + """); boolean finishedWithoutTimeout = waitForPassCondition(childCompleted::get); browserChild.dispose(); @@ -1720,7 +1730,10 @@ public void test_getText_script() { if (SwtTestUtil.isWindows) { // Windows' Browser implementation returns the processed HTML rather than the original one. // The processed page injects "style" property into the body from the script. - getText_helper(testString, "hello World"); + getText_helper(testString, """ + hello World + + """); } else { // Linux Webkit1, Webkit2 // Cocoa @@ -2154,16 +2167,19 @@ public Object function(Object[] arguments) { } } - String htmlWithScript = "\n" - + "\n" - + "\n" - + " Going to make a callback to Java \n" - + "\n"; + // Define a javascript function and calls it + String htmlWithScript = """ + + + + Going to make a callback to Java + + """; browser.setText(htmlWithScript); new JavascriptCallback(browser, "jsCallbackToJava"); @@ -2197,16 +2213,19 @@ public Object function(Object[] arguments) { } } - String htmlWithScript = "\n" - + "\n" - + "\n" - + " Going to make a callback to Java \n" - + "\n"; + // Define a javascript function and calls it with value of 5 + String htmlWithScript = """ + + + + Going to make a callback to Java + + """; browser.setText(htmlWithScript); new JavascriptCallback(browser, "jsCallbackToJava"); @@ -2241,17 +2260,19 @@ public Object function(Object[] arguments) { return null; } } - - String htmlWithScript = "\n" - + "\n" - + "\n" - + " Going to make a callback to Java \n" - + "\n"; + // Define a javascript function and call it + String htmlWithScript = """ + + + + Going to make a callback to Java + + """; browser.setText(htmlWithScript); new JavascriptCallback(browser, "jsCallbackToJava"); @@ -2285,16 +2306,19 @@ public Object function(Object[] arguments) { } } - String htmlWithScript = "\n" - + "\n" - + "\n" - + " Going to make a callback to Java \n" - + "\n"; + // Define a javascript function and call it + String htmlWithScript = """ + + + + Going to make a callback to Java + + """; browser.setText(htmlWithScript); new JavascriptCallback(browser, "jsCallbackToJava"); @@ -2332,16 +2356,19 @@ public Object function(Object[] arguments) { } } - String htmlWithScript = "\n" - + "\n" - + "\n" - + " Going to make a callback to Java \n" - + "\n"; + // Define a javascript function and call it + String htmlWithScript = """ + + + + Going to make a callback to Java + + """; browser.setText(htmlWithScript); new JavascriptCallback(browser, "jsCallbackToJava"); @@ -2410,19 +2437,21 @@ public Object function(Object[] arguments) { return null; } } - - String htmlWithScript = "\n" - + "\n" - + "\n" - + " If you see this, Javascript did not receive anything from Java. This page should just be '42' \n" - + "\n"; + // Define a javascript function and call it, return value to be checked in html body + String htmlWithScript = """ + + + + If you see this, Javascript did not receive anything from Java. This page should just be '42' + + """; // 1) browser.setText(htmlWithScript); new JavascriptCallback(browser, "jsCallbackToJava");