blob: 8cfb9eb36d04edc97c80410c22e7e4287ba39f13 (
plain)
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
|
package com.vaadin.tests.themes.valo;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.tests.ModalWindow;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class ModalWindowTest extends SingleBrowserTest {
@Override
protected Class<?> getUIClass() {
return ModalWindow.class;
}
@Test
public void modalAnimationsAreDisabled() {
openTestURL("theme=tests-valo-disabled-animations");
openModalWindow();
WebElement modalityCurtain = findElement(
By.className("v-window-modalitycurtain"));
assertThat(modalityCurtain.getCssValue("-webkit-animation-name"),
is("none"));
}
@Test
public void modal_curtains_close_correctly() {
openTestURL();
openModalWindow();
new Actions(getDriver()).moveToElement(findHeaderElement())
.clickAndHold().moveByOffset(1, 1).perform();
assertTrue(isElementPresent(By.className("v-window-draggingCurtain")));
new Actions(getDriver()).sendKeys(findHeaderElement(), Keys.ESCAPE)
.release().perform();
verifyCurtainsNotPresent();
openModalWindow();
new Actions(getDriver()).moveToElement(findResizingElement())
.clickAndHold().moveByOffset(1, 1).perform();
assertTrue(isElementPresent(By.className("v-window-resizingCurtain")));
new Actions(getDriver()).sendKeys(findResizingElement(), Keys.ESCAPE)
.release().perform();
verifyCurtainsNotPresent();
}
private void openModalWindow() {
$(ButtonElement.class).get(1).click();
}
private WebElement findHeaderElement() {
return findElement(By.className("v-window-header"));
}
private WebElement findResizingElement() {
return findElement(By.className("v-window-resizebox"));
}
private void verifyCurtainsNotPresent() {
assertFalse(isElementPresent(By.className("v-window-modalitycurtain")));
assertFalse(isElementPresent(By.className("v-window-draggingCurtain")));
assertFalse(isElementPresent(By.className("v-window-resizingCurtain")));
}
}
|