use of com.gargoylesoftware.htmlunit.StatusHandler in project htmlunit by HtmlUnit.
the class HtmlObjectTest method checkAppletBase.
/**
* Tests the codebase and documentbase properties.
* @throws Exception if the test fails
*/
@Test
public void checkAppletBase() throws Exception {
Assume.assumeFalse(SKIP_);
if (getBrowserVersion().isChrome()) {
return;
}
final URL url = getClass().getResource("/objects/codebaseApplet.html");
final WebClient webClient = getWebClient();
final List<String> collectedStatus = new ArrayList<>();
final StatusHandler statusHandler = new StatusHandler() {
@Override
public void statusMessageChanged(final Page page, final String message) {
collectedStatus.add(message);
}
};
webClient.setStatusHandler(statusHandler);
webClient.getOptions().setAppletEnabled(true);
final HtmlPage page = webClient.getPage(url);
HtmlButton button = page.getHtmlElementById("buttonShowCodeBase");
button.click();
button = page.getHtmlElementById("buttonShowDocumentBase");
button.click();
assertEquals(2, collectedStatus.size());
assertTrue(collectedStatus.get(0), collectedStatus.get(0).startsWith("CodeBase: 'file:"));
assertTrue(collectedStatus.get(0), collectedStatus.get(0).endsWith("target/test-classes/objects/'"));
assertTrue(collectedStatus.get(1), collectedStatus.get(1).startsWith("DocumentBase: 'file:"));
assertTrue(collectedStatus.get(1), collectedStatus.get(1).endsWith("target/test-classes/objects/codebaseApplet.html'"));
}
use of com.gargoylesoftware.htmlunit.StatusHandler in project htmlunit by HtmlUnit.
the class HtmlObjectTest method checkAppletExecJs.
/**
* @throws Exception if the test fails
*/
@Test
public void checkAppletExecJs() throws Exception {
Assume.assumeFalse(SKIP_);
if (getBrowserVersion().isChrome()) {
return;
}
final URL url = getClass().getResource("/objects/simpleAppletDoIt.html");
final WebClient webClient = getWebClient();
final List<String> collectedStatus = new ArrayList<>();
final StatusHandler statusHandler = new StatusHandler() {
@Override
public void statusMessageChanged(final Page page, final String message) {
collectedStatus.add(message);
}
};
webClient.setStatusHandler(statusHandler);
webClient.getOptions().setAppletEnabled(true);
final HtmlPage page = webClient.getPage(url);
final HtmlButton button = page.getHtmlElementById("execJs7");
button.click();
assertEquals(2, collectedStatus.size());
assertEquals("execJS: '7'", collectedStatus.get(0));
assertEquals(" '7.0'", collectedStatus.get(1));
}
use of com.gargoylesoftware.htmlunit.StatusHandler in project htmlunit by HtmlUnit.
the class HtmlObjectTest method checkSubdirAppletBase.
/**
* Tests the codebase and documentbase properties.
* @throws Exception if the test fails
*/
@Test
public void checkSubdirAppletBase() throws Exception {
Assume.assumeFalse(SKIP_);
if (getBrowserVersion().isChrome()) {
return;
}
final URL url = getClass().getResource("/objects/subdir/codebaseApplet.html");
final WebClient webClient = getWebClient();
final List<String> collectedStatus = new ArrayList<>();
final StatusHandler statusHandler = new StatusHandler() {
@Override
public void statusMessageChanged(final Page page, final String message) {
collectedStatus.add(message);
}
};
webClient.setStatusHandler(statusHandler);
webClient.getOptions().setAppletEnabled(true);
final HtmlPage page = webClient.getPage(url);
HtmlButton button = page.getHtmlElementById("buttonShowCodeBase");
button.click();
button = page.getHtmlElementById("buttonShowDocumentBase");
button.click();
assertEquals(2, collectedStatus.size());
assertTrue(collectedStatus.get(0), collectedStatus.get(0).startsWith("CodeBase: 'file:"));
assertTrue(collectedStatus.get(0), collectedStatus.get(0).endsWith("target/test-classes/objects/'"));
assertTrue(collectedStatus.get(1), collectedStatus.get(1).startsWith("DocumentBase: 'file:"));
assertTrue(collectedStatus.get(1), collectedStatus.get(1).endsWith("target/test-classes/objects/subdir/codebaseApplet.html'"));
}
Aggregations