1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.libraries;
16
17 import java.net.URL;
18
19 import org.eclipse.jetty.server.Server;
20 import org.htmlunit.WebDriverTestCase;
21 import org.htmlunit.WebServerTestCase;
22 import org.htmlunit.junit.BrowserRunner;
23 import org.junit.AfterClass;
24 import org.junit.BeforeClass;
25 import org.junit.Ignore;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.openqa.selenium.JavascriptExecutor;
29 import org.openqa.selenium.WebDriver;
30
31
32
33
34
35
36 @RunWith(BrowserRunner.class)
37 public class ChartJs4x4x6Test extends WebDriverTestCase {
38
39
40 protected static Server SERVER_;
41
42
43
44
45 @BeforeClass
46 public static void startSesrver() throws Exception {
47 SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/chartjs/4.4.6/", null);
48 }
49
50
51
52
53 @AfterClass
54 public static void stopServer() throws Exception {
55 if (SERVER_ != null) {
56 SERVER_.stop();
57 SERVER_.destroy();
58 SERVER_ = null;
59 }
60 }
61
62
63
64
65 protected URL getBaseUrl() {
66 return URL_FIRST;
67 }
68
69
70
71
72 @Test
73 @Ignore("Fails because of the missing spread support")
74 public void simpleBarChart() throws Exception {
75 doTest("simple_bar_chart");
76 }
77
78 private void doTest(final String filename) throws Exception {
79 final WebDriver driver = getWebDriver();
80 driver.get(getBaseUrl() + filename + ".html");
81
82
83 ((JavascriptExecutor) driver).executeScript("return document.getElementById('myLog').value = "
84 + "document.getElementById('myChart').toDataURL('image/png') + '§'");
85 final String expected = loadExpectation("/libraries/chartjs/4.4.6/expectations/" + filename, ".expected");
86 verifyTextArea2(driver, expected);
87 }
88 }