View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.bean.html5;
18  
19  import static org.apache.juneau.bean.html5.HtmlBuilder.*;
20  import static org.apache.juneau.junit.bct.BctAssertions.*;
21  
22  import org.apache.juneau.*;
23  import org.junit.jupiter.api.*;
24  
25  class Button_Test extends TestBase {
26  
27  	@Test void a01_basicSetters() {
28  		Button x = button()
29  			.autofocus("a")
30  			.disabled("b")
31  			.form("c")
32  			.formaction("d")
33  			.formenctype("e")
34  			.formmethod("f")
35  			.formnovalidate("g")
36  			.formtarget("h")
37  			.menu("i")
38  			.name("j")
39  			.type("k")
40  			.value("l")
41  			._class("m")
42  			.accesskey("n")
43  			.contenteditable("o")
44  			.dir("p")
45  			.hidden("q")
46  			.id("r")
47  			.lang("s")
48  			.onabort("t")
49  			.onblur("u")
50  			.oncancel("v")
51  			.oncanplay("w")
52  			.oncanplaythrough("x")
53  			.onchange("y")
54  			.onclick("z")
55  			.oncuechange("aa")
56  			.ondblclick("ab")
57  			.ondurationchange("ac")
58  			.onemptied("ad")
59  			.onended("ae")
60  			.onerror("af")
61  			.onfocus("ag")
62  			.oninput("ah")
63  			.oninvalid("ai")
64  			.onkeydown("aj")
65  			.onkeypress("ak")
66  			.onkeyup("al")
67  			.onload("am")
68  			.onloadeddata("an")
69  			.onloadedmetadata("ao")
70  			.onloadstart("ap")
71  			.onmousedown("aq")
72  			.onmouseenter("ar")
73  			.onmouseleave("as")
74  			.onmousemove("at")
75  			.onmouseout("au")
76  			.onmouseover("av")
77  			.onmouseup("aw")
78  			.onmousewheel("ax")
79  			.onpause("ay")
80  			.onplay("az")
81  			.onplaying("ba")
82  			.onprogress("bb")
83  			.onratechange("bc")
84  			.onreset("bd")
85  			.onresize("be")
86  			.onscroll("bf")
87  			.onseeked("bg")
88  			.onseeking("bh")
89  			.onselect("bi")
90  			.onshow("bj")
91  			.onstalled("bk")
92  			.onsubmit("bl")
93  			.onsuspend("bm")
94  			.ontimeupdate("bn")
95  			.ontoggle("bo")
96  			.onvolumechange("bp")
97  			.onwaiting("bq")
98  			.spellcheck("br")
99  			.style("bs")
100 			.tabindex("bt")
101 			.title("bu")
102 			.translate("bv")
103 			.children("bw", strong("bx"));
104 
105 		assertString(
106 			"<button autofocus='a' disabled='b' form='c' formaction='d' formenctype='e' formmethod='f' formnovalidate='g' formtarget='h' menu='i' name='j' type='k' value='l' class='m' accesskey='n' contenteditable='o' dir='p' hidden='q' id='r' lang='s' onabort='t' onblur='u' oncancel='v' oncanplay='w' oncanplaythrough='x' onchange='y' onclick='z' oncuechange='aa' ondblclick='ab' ondurationchange='ac' onemptied='ad' onended='ae' onerror='af' onfocus='ag' oninput='ah' oninvalid='ai' onkeydown='aj' onkeypress='ak' onkeyup='al' onload='am' onloadeddata='an' onloadedmetadata='ao' onloadstart='ap' onmousedown='aq' onmouseenter='ar' onmouseleave='as' onmousemove='at' onmouseout='au' onmouseover='av' onmouseup='aw' onmousewheel='ax' onpause='ay' onplay='az' onplaying='ba' onprogress='bb' onratechange='bc' onreset='bd' onresize='be' onscroll='bf' onseeked='bg' onseeking='bh' onselect='bi' onshow='bj' onstalled='bk' onsubmit='bl' onsuspend='bm' ontimeupdate='bn' ontoggle='bo' onvolumechange='bp' onwaiting='bq' spellcheck='br' style='bs' tabindex='bt' title='bu' translate='bv'>bw<strong>bx</strong></button>",
107 			x
108 		);
109 	}
110 
111 	@Test void a02_emptyBean() {
112 		assertString("<button></button>", button());
113 	}
114 
115 	@Test void a03_otherConstructors() {
116 		Button x1 = new Button("a");
117 		assertString("<button type='a'></button>", x1);
118 
119 		Button x2 = new Button("a", "b1", strong("b2"));
120 		assertString("<button type='a'>b1<strong>b2</strong></button>", x2);
121 
122 	}
123 }