1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import org.htmlunit.SimpleWebTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.htmlunit.junit.annotation.HtmlUnitNYI;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23
24
25
26
27
28
29
30 @RunWith(BrowserRunner.class)
31 public class HtmlWeekInput2Test extends SimpleWebTestCase {
32
33
34
35
36 @Test
37 @Alerts({"true", "false", "true", "true", "true", "true"})
38 @HtmlUnitNYI(FF = {"true", "true", "true", "true", "true", "true"},
39 FF_ESR = {"true", "true", "true", "true", "true", "true"})
40 public void minValidation() throws Exception {
41 final String htmlContent = DOCTYPE_HTML
42 + "<html>\n"
43 + "<head></head>\n"
44 + "<body>\n"
45 + "<form id='form1'>\n"
46 + " <input type='week' id='first' min='2018-W10'>\n"
47 + " <input type='week' id='second'>\n"
48 + " <input type='week' id='third' min='foo'>\n"
49 + "</form>\n"
50 + "</body></html>";
51
52 final HtmlPage page = loadPage(htmlContent);
53
54 final HtmlWeekInput first = (HtmlWeekInput) page.getElementById("first");
55 final HtmlWeekInput second = (HtmlWeekInput) page.getElementById("second");
56 final HtmlWeekInput third = (HtmlWeekInput) page.getElementById("third");
57
58
59 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
60
61 first.setValue("2018-W09");
62 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
63
64 first.setValue("2018-W10");
65 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
66
67 first.setValue("2018-W11");
68 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
69
70 second.setValue("2018-W10");
71 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
72 third.setValue("2018-W10");
73 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
74 }
75
76
77
78
79 @Test
80 @Alerts({"true", "true", "true", "false", "true", "true"})
81 @HtmlUnitNYI(FF = {"true", "true", "true", "true", "true", "true"},
82 FF_ESR = {"true", "true", "true", "true", "true", "true"})
83 public void naxValidation() throws Exception {
84 final String htmlContent = DOCTYPE_HTML
85 + "<html>\n"
86 + "<head></head>\n"
87 + "<body>\n"
88 + "<form id='form1'>\n"
89 + " <input type='week' id='first' max='2018-W10'>\n"
90 + " <input type='week' id='second'>\n"
91 + " <input type='week' id='third' max='foo'>\n"
92 + "</form>\n"
93 + "</body></html>";
94
95 final HtmlPage page = loadPage(htmlContent);
96
97 final HtmlWeekInput first = (HtmlWeekInput) page.getElementById("first");
98 final HtmlWeekInput second = (HtmlWeekInput) page.getElementById("second");
99 final HtmlWeekInput third = (HtmlWeekInput) page.getElementById("third");
100
101
102 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
103
104 first.setValue("2018-W09");
105 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
106
107 first.setValue("2018-W10");
108 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
109
110 first.setValue("2018-W11");
111 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
112
113 second.setValue("2018-W10");
114 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
115 third.setValue("2018-W10");
116 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
117 }
118 }