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 HtmlMonthInput2Test 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='month' id='first' min='2018-12'>\n"
47 + " <input type='month' id='second'>\n"
48 + " <input type='month' id='third' min='foo'>\n"
49 + "</form>\n"
50 + "</body></html>";
51
52 final HtmlPage page = loadPage(htmlContent);
53
54 final HtmlMonthInput first = (HtmlMonthInput) page.getElementById("first");
55 final HtmlMonthInput second = (HtmlMonthInput) page.getElementById("second");
56 final HtmlMonthInput third = (HtmlMonthInput) page.getElementById("third");
57
58
59 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
60
61 first.setValue("2018-11");
62 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
63
64 first.setValue("2018-12");
65 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
66
67 first.setValue("2018-12");
68 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
69
70 second.setValue("2018-11");
71 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
72 assertTrue(second.isValid());
73 third.setValue("2018-11");
74 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
75 }
76
77
78
79
80 @Test
81 @Alerts({"true", "true", "true", "false", "true", "true"})
82 @HtmlUnitNYI(FF = {"true", "true", "true", "true", "true", "true"},
83 FF_ESR = {"true", "true", "true", "true", "true", "true"})
84 public void maxValidation() throws Exception {
85 final String htmlContent = DOCTYPE_HTML
86 + "<html>\n"
87 + "<head></head>\n"
88 + "<body>\n"
89 + "<form id='form1'>\n"
90 + " <input type='month' id='first' max='2018-12'>\n"
91 + " <input type='month' id='second'>\n"
92 + " <input type='month' id='third' max='foo'>\n"
93 + "</form>\n"
94 + "</body></html>";
95
96 final HtmlPage page = loadPage(htmlContent);
97
98 final HtmlMonthInput first = (HtmlMonthInput) page.getElementById("first");
99 final HtmlMonthInput second = (HtmlMonthInput) page.getElementById("second");
100 final HtmlMonthInput third = (HtmlMonthInput) page.getElementById("third");
101
102
103 assertEquals(getExpectedAlerts()[0], Boolean.toString(first.isValid()));
104
105 first.setValue("2018-11");
106 assertEquals(getExpectedAlerts()[1], Boolean.toString(first.isValid()));
107
108 first.setValue("2018-12");
109 assertEquals(getExpectedAlerts()[2], Boolean.toString(first.isValid()));
110
111 first.setValue("2019-01");
112 assertEquals(getExpectedAlerts()[3], Boolean.toString(first.isValid()));
113
114 second.setValue("2018-12");
115 assertEquals(getExpectedAlerts()[4], Boolean.toString(second.isValid()));
116 third.setValue("2018-12");
117 assertEquals(getExpectedAlerts()[5], Boolean.toString(third.isValid()));
118 }
119 }