diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-12-12 11:14:23 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-01-16 17:35:12 +0000 |
commit | 54e577da4503d417f3607f71820b545098c917ec (patch) | |
tree | 97ff5e96646edd2f1e0eead7a3ee3576718b5b7d /uitest/src/com/vaadin/tests/components/window | |
parent | 836a396fcc38752f211fbccad7ddb455d7d24d16 (diff) | |
download | vaadin-framework-54e577da4503d417f3607f71820b545098c917ec.tar.gz vaadin-framework-54e577da4503d417f3607f71820b545098c917ec.zip |
Fix maximized window ordering. (#15360)
Change-Id: Ic994d4e5d74ddc2a554311110640b84bc2e9c802
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/window')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrder.java | 49 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/window/MaximizedWindowOrderTest.java | 70 |
2 files changed, 119 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 |