summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-12-12 11:14:23 +0200
committerArtur Signell <artur@vaadin.com>2015-01-16 17:35:12 +0000
commit54e577da4503d417f3607f71820b545098c917ec (patch)
tree97ff5e96646edd2f1e0eead7a3ee3576718b5b7d /uitest
parent836a396fcc38752f211fbccad7ddb455d7d24d16 (diff)
downloadvaadin-framework-54e577da4503d417f3607f71820b545098c917ec.tar.gz
vaadin-framework-54e577da4503d417f3607f71820b545098c917ec.zip
Fix maximized window ordering. (#15360)
Change-Id: Ic994d4e5d74ddc2a554311110640b84bc2e9c802
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrder.java49
-rw-r--r--uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrderTest.java70
-rw-r--r--uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java53
3 files changed, 172 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrder.java b/uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrder.java
new file mode 100644
index 0000000000..8fe6c0ce5a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrder.java
@@ -0,0 +1,49 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.window.WindowMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class MaximizedWindowOrder extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addButton("Open Maximized Window", new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ openWindow(true);
+ }
+ });
+ }
+
+ private void openWindow(boolean maximized) {
+ Window window = new Window();
+ VerticalLayout layout = new VerticalLayout();
+
+ Label label = new Label(maximized ? "Maximized" : "Normal");
+
+ layout.addComponent(label);
+ Button button = new Button("Open Normal Window");
+ button.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ openWindow(false);
+ }
+
+ });
+
+ layout.addComponent(button);
+
+ window.setContent(layout);
+ window.setWindowMode(maximized ? WindowMode.MAXIMIZED : WindowMode.NORMAL);
+
+ addWindow(window);
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrderTest.java b/uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrderTest.java
new file mode 100644
index 0000000000..5063c84658
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrderTest.java
@@ -0,0 +1,70 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.AbstractTB3Test;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.tb3.newelements.WindowElement;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertThat;
+
+public class MaximizedWindowOrderTest extends MultiBrowserTest {
+
+ private WindowElement openAnotherWindow() {
+ WindowElement maximizedWindow = getMaximizedWindow();
+ maximizedWindow.$(ButtonElement.class).first().click();
+
+ return getAnotherWindow();
+ }
+
+ private WindowElement getMaximizedWindow() {
+ return $(WindowElement.class).first();
+ }
+
+ private WindowElement getAnotherWindow() {
+ return $(WindowElement.class).get(1);
+ }
+
+ private WindowElement openMaximizedWindow() {
+ $(ButtonElement.class).first().click();
+
+ return getMaximizedWindow();
+ }
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ }
+
+ @Test
+ public void newWindowOpensOnTopOfMaximizedWindow() {
+ WindowElement maximizedWindow = openMaximizedWindow();
+ WindowElement anotherWindow = openAnotherWindow();
+
+ assertThat(anotherWindow.getCssValue("z-index"),
+ is(greaterThan(maximizedWindow.getCssValue("z-index"))));
+
+ assertThat(getMaximizedWindow().getCssValue("z-index"), is("10000"));
+ assertThat(getAnotherWindow().getCssValue("z-index"), is("10001"));
+ }
+
+ @Test
+ public void backgroundWindowIsBroughtOnTopWhenMaximized() {
+ WindowElement maximizedWindow = openMaximizedWindow();
+
+ maximizedWindow.restore();
+
+ // the new window is opened on top of the original.
+ WindowElement anotherWindow = openAnotherWindow();
+
+ // move the window to make the maximize button visible.
+ anotherWindow.move(10, 20);
+ maximizedWindow.maximize();
+
+ assertThat(maximizedWindow.getCssValue("z-index"),
+ is(greaterThan(anotherWindow.getCssValue("z-index"))));
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java b/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java
new file mode 100644
index 0000000000..dd7cb55d01
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/newelements/WindowElement.java
@@ -0,0 +1,53 @@
+package com.vaadin.tests.tb3.newelements;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ServerClass;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+/*
+ Suggestions for new elemental api for Window
+ */
+@ServerClass("com.vaadin.ui.Window")
+public class WindowElement extends com.vaadin.testbench.elements.WindowElement {
+
+ private final String restoreBoxClass = "v-window-restorebox";
+ private final String maximizeBoxClass = "v-window-maximizebox";
+
+ public void restore() {
+ if(isMaximized()) {
+ getRestoreButton().click();
+ } else {
+ throw new AssertionError("Window is not maximized, cannot be restored.");
+ }
+ }
+
+ private boolean isMaximized() {
+ return isElementPresent(By.className(restoreBoxClass));
+ }
+
+ private WebElement getRestoreButton() {
+ return this.findElement(By.className("v-window-restorebox"));
+ }
+
+ public void maximize() {
+ if(!isMaximized()) {
+ getMaximizeButton().click();
+ } else {
+ throw new AssertionError("Window is already maximized, cannot maximize.");
+ }
+ }
+
+ private WebElement getMaximizeButton() {
+ return this.findElement(By.className(maximizeBoxClass));
+ }
+
+ public void move(int xOffset, int yOffset) {
+ Actions action = new Actions(getDriver());
+ action.moveToElement(this.findElement(org.openqa.selenium.By.className("v-window-wrap")), 5, 5);
+ action.clickAndHold();
+ action.moveByOffset(xOffset, yOffset);
+ action.release();
+ action.build().perform();
+ }
+}