1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.themes.valo;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.CssLayoutElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.TreeElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class ValoThemeUITest extends MultiBrowserTest {
@Test
public void labels() throws Exception {
openTestURL("test");
open("Labels");
compareScreen("labels");
}
@Test
public void buttonsLinks() throws Exception {
openTestURL("test");
open("Buttons & Links", "Buttons");
compareScreen("buttonsLinks");
}
@Test
public void textFields() throws Exception {
openTestURL("test");
open("Text Fields <span class=\"valo-menu-badge\">123</span>",
"Text Fields");
compareScreen("textFields");
}
@Test
public void common() throws Exception {
openTestURL("test");
open("Common UI Elements");
compareScreen("common");
}
@Test
public void datefields() throws Exception {
openTestURL("test");
open("Date Fields");
// Note that this can look broken in IE9 because of some browser
// rendering issue... The problem seems to be in the customized
// horizontal layout in the test app
compareScreen("datefields-with-range");
}
@Test
public void comboboxes() throws Exception {
openTestURL("test");
open("Combo Boxes");
compareScreen("comboboxes");
}
@Test
public void selects() throws Exception {
openTestURL("test");
open("Selects");
compareScreen("selects");
}
@Test
public void checkboxes() throws Exception {
openTestURL("test");
open("Check Boxes & Option Groups", "Check Boxes");
compareScreen("checkboxes");
}
@Test
public void sliders() throws Exception {
openTestURL("test");
open("Sliders & Progress Bars", "Sliders");
compareScreen("sliders");
}
@Test
public void colorpickers() throws Exception {
openTestURL("test");
open("Color Pickers");
compareScreen("colorpickers");
}
@Test
public void menubars() throws Exception {
openTestURL("test");
open("Menu Bars");
compareScreen("menubars");
}
@Test
public void trees() throws Exception {
openTestURL("test");
open("Trees");
selectTreeNodeByCaption("Quid securi");
compareScreen("trees");
}
private void selectTreeNodeByCaption(String string) {
WebElement e = $(TreeElement.class).first().findElement(
By.xpath("//div[@class='v-tree-node-caption']//span[text()='"
+ string + "']"));
e.click();
}
@Test
public void tables() throws Exception {
openTestURL("test");
open("Tables");
check("Components in Cells");
compareScreen("tables");
}
@Test
public void treeTables() throws Exception {
openTestURL("test");
open("Tables");
check("Hierarchical");
check("Footer");
compareScreen("treetables");
}
@Test
public void dragging() throws Exception {
openTestURL("test");
open("Drag and Drop", "Dragging Components");
compareScreen("dragging");
}
@Test
public void panels() throws Exception {
openTestURL("test");
open("Panels", "Panels & Layout panels");
compareScreen("panels");
}
@Test
public void splitpanels() throws Exception {
openTestURL("test");
open("Split Panels");
compareScreen("splitpanels");
}
@Test
public void tabs() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
compareScreen("tabs");
}
@Test
public void tabsClosable() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
check("Closable");
check("Disable tabs");
check("Overflow");
compareScreen("tabs-closable-disabled");
}
@Test
public void tabsClosableUnframed() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
check("Closable");
// Framed option is checked by default so we are actually unchecking
check("Framed");
check("Overflow");
compareScreen("tabs-closable-unframed");
}
@Test
public void tabsAlignRight() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
check("Right-aligned tabs");
compareScreen("tabs-align-right");
}
/**
* workaround for http://dev.vaadin.com/ticket/13763
*/
private void check(String caption) {
WebElement cb = $(CheckBoxElement.class).caption(caption).first()
.findElement(By.xpath("input"));
if (BrowserUtil.isChrome(getDesiredCapabilities())) {
testBenchElement(cb).click(0, 0);
} else {
cb.click();
}
}
@Test
public void tabsAlignCenter() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
check("Centered tabs");
compareScreen("tabs-align-center");
}
@Test
public void tabsIconsOnTop() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
check("Icons on top");
compareScreen("tabs-icons-on-top");
}
@Test
public void tabsEqualCompactPadded() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
check("Equal-width tabs");
check("Padded tabbar");
check("Compact");
compareScreen("tabs-equal-compact-padded");
}
@Test
public void accordions() throws Exception {
openTestURL("test");
open("Accordions");
compareScreen("accordions");
}
@Test
public void popupviews() throws Exception {
openTestURL("test");
open("Popup Views");
scrollTo(500, 0);
compareScreen("popupviews");
}
@Test
public void calendar() throws Exception {
openTestURL("test");
scrollTo(500, 0);
open("Calendar");
compareScreen("calendar");
}
@Test
public void forms() throws Exception {
openTestURL("test");
scrollTo(500, 0);
open("Forms");
compareScreen("forms");
}
private void open(String link) {
open(link, link);
}
private void open(String link, String caption) {
open(link, caption, 10);
}
// FIXME: Remove this once click works properly on IE...
private void open(String link, String caption, int tries) {
if (tries <= 0) {
throw new RuntimeException(
"Tried many times but was not able to click the link...");
}
$(ButtonElement.class).caption(link).first().click();
CssLayoutElement content = wrap(CssLayoutElement.class,
findElement(By.className("valo-content")));
LabelElement captionElem = content.$(LabelElement.class).first();
if (!captionElem.getText().equals(caption)) {
// IE ... why you fail clicks
System.err.println("Extra click needed on '" + link
+ "' on remote " + getDesiredCapabilities() + " "
+ getRemoteControlName());
open(link, caption, tries - 1);
} else {
// Done opening, scroll left panel to the top again for consistency
scrollTo(0, 0);
}
}
private void scrollTo(int top, int left) {
CssLayoutElement testMenu = $(CssLayoutElement.class).id("testMenu");
testBenchElement(testMenu).scroll(top);
testBenchElement(testMenu).scrollLeft(left);
}
@Override
protected boolean requireWindowFocusForIE() {
return true;
}
@Override
protected boolean usePersistentHoverForIE() {
return false;
}
}
|