Skip to content

Commit 14c2730

Browse files
committed
use std log
1 parent 17a61e5 commit 14c2730

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

src/test/java/org/htmlunit/general/HostConstantsTest.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import org.junit.runner.RunWith;
3535
import org.junit.runners.Parameterized.Parameter;
3636
import org.junit.runners.Parameterized.Parameters;
37-
import org.openqa.selenium.By;
38-
import org.openqa.selenium.WebDriver;
3937

4038
/**
4139
* Test all {@code constant}s defined in host classes.
@@ -80,9 +78,7 @@ public void test() throws Exception {
8078

8179
final String html = "<html><head>\n"
8280
+ "<script>\n"
83-
+ "function log(x) {\n"
84-
+ " document.getElementById('log').value += x + '\\n';\n"
85-
+ "}\n"
81+
+ LOG_TEXTAREA_FUNCTION
8682
+ "function test() {\n"
8783
+ " try {\n"
8884
+ " var all = [];\n"
@@ -103,31 +99,27 @@ public void test() throws Exception {
10399
// + " }\n"
104100
// + " alert(string);\n"
105101

106-
+ " var string = '';\n"
107102
+ " for (var i in all) {\n"
108103
+ " var x = all[i];\n"
109-
+ " string += x + ':' + " + host_ + "[x] + ' ';\n"
104+
+ " log(x + ':' + " + host_ + "[x]);\n"
110105
+ " }\n"
111-
+ " log(string);\n"
112106
+ " } catch (e) {}\n"
113107
+ "}\n"
114108
+ "</script>\n"
115109
+ "</head>\n"
116110
+ "<body onload='test()'>\n"
117-
+ " <textarea id='log' cols='80' rows='40'></textarea>\n"
111+
+ LOG_TEXTAREA
118112
+ "</body></html>";
119113

120-
final WebDriver driver = loadPage2(html);
121-
final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", "");
122-
assertEquals(String.join("\n", getExpectedAlerts()), text);
114+
loadPageVerifyTextArea2(html);
123115
}
124116

125-
private String getExpectedString() throws Exception {
117+
private String[] getExpectedString() throws Exception {
126118
if (host_.endsWith("Array") || "Image".equals(host_) || "Option".equals(host_)) {
127-
return "";
119+
return new String[0];
128120
}
129121
if ("Error".equals(host_) && getBrowserVersion().hasFeature(JS_ERROR_STACK_TRACE_LIMIT)) {
130-
return "stackTraceLimit:10";
122+
return new String[] {"stackTraceLimit:10"};
131123
}
132124

133125
final JavaScriptConfiguration javaScriptConfig = JavaScriptConfiguration.getInstance(getBrowserVersion());
@@ -157,11 +149,7 @@ public int compare(final String o1, final String o2) {
157149
return o1.substring(0, o1.indexOf(':')).compareTo(o2.substring(0, o2.indexOf(':')));
158150
}
159151
});
160-
final StringBuilder builder = new StringBuilder();
161-
for (final String key : constants) {
162-
builder.append(key).append(' ');
163-
}
164-
return builder.toString().trim();
152+
return constants.toArray(new String[0]);
165153
}
166154

167155
/**

0 commit comments

Comments
 (0)