diff options
author | Patrik Lindström <patrik@vaadin.com> | 2013-11-06 15:19:50 +0200 |
---|---|---|
committer | Patrik Lindström <patrik@vaadin.com> | 2013-11-06 15:27:36 +0200 |
commit | a12b62485dfa9c294e1a483c4b340c2be6a53588 (patch) | |
tree | 037c8e12d1c057ece0c3b3edc22573cbbf324449 /uitest/src/com | |
parent | 5b8b824942019ab6fc9d70263c22de3644f1f785 (diff) | |
parent | 533ddcda271b7226b38c035adf3073062c562653 (diff) | |
download | vaadin-framework-a12b62485dfa9c294e1a483c4b340c2be6a53588.tar.gz vaadin-framework-a12b62485dfa9c294e1a483c4b340c2be6a53588.zip |
Merge remote-tracking branch 'origin/7.1' into testbench4
Change-Id: If596876f0a17c471dc7db6b6eea25ed1c3b87fb1
Diffstat (limited to 'uitest/src/com')
33 files changed, 1532 insertions, 1061 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html new file mode 100644 index 0000000000..6fd54ba0ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>TableHorizontalScrollPositionOnItemSetChange</title> +</head> +<body> + <table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">TableHorizontalScrollPositionOnItemSetChange</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.TableHorizontalScrollPositionOnItemSetChange?restartApplication</td> + <td></td> + </tr> + <tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]</td> + <td>326</td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Slessitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-in-middle-with-fewer-items</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Smoreitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-in-middle-with-more-items</td> + </tr> + <tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]</td> + <td>653</td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Slessitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-max-with-fewer-items</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Smoreitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-max-with-more-items</td> + </tr> + <tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]</td> + <td>0</td> + </tr> + </tbody> + </table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java new file mode 100644 index 0000000000..1f59a84428 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2013 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.components.table; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +public class TableHorizontalScrollPositionOnItemSetChange extends + AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + layout.setSpacing(true); + setContent(layout); + + final Table table = new Table(); + table.setWidth("640px"); + table.setHeight("243px"); + table.setId("horscrolltable"); + layout.addComponent(table); + + for (int i = 0; i < 15; i++) { + table.addContainerProperty("Column " + i, String.class, null); + } + + for (int i = 0; i < 60; i++) { + table.addItem(); + } + + Button lessItems = new Button("Less items", new Button.ClickListener() { + + @Override + public void buttonClick(Button.ClickEvent event) { + table.removeAllItems(); + for (int i = 0; i < 5; i++) { + table.addItem(); + } + } + }); + lessItems.setId("lessitems"); + + Button moreItems = new Button("More items", new Button.ClickListener() { + + @Override + public void buttonClick(Button.ClickEvent event) { + table.removeAllItems(); + for (int i = 0; i < 50; i++) { + table.addItem(); + } + } + }); + moreItems.setId("moreitems"); + + Button clearItems = new Button("Clear all", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + table.removeAllItems(); + } + }); + + HorizontalLayout buttonLayout = new HorizontalLayout(); + buttonLayout.setSpacing(true); + layout.addComponent(buttonLayout); + + buttonLayout.addComponent(lessItems); + buttonLayout.addComponent(moreItems); + buttonLayout.addComponent(clearItems); + clearItems.setId("clearitems"); + } + + @Override + protected String getTestDescription() { + return "Horizontal scrolling position should not be lost if amount of items changes in Table."; + } + + @Override + protected Integer getTicketNumber() { + return 12652; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheet.java b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheet.java new file mode 100644 index 0000000000..f84f83718d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheet.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2013 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.components.table; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.Layout; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class TableSizeInTabsheet extends AbstractTestUI { + + static final String TABLE = "table"; + static final String TABSHEET = "tabsheet"; + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + TabSheet tabSheet = new TabSheet(); + tabSheet.setId(TABSHEET); + layout.addComponent(tabSheet); + tabSheet.addTab(new TabComposite(), "Tab"); + } + + public class TabComposite extends CustomComponent { + + public TabComposite() { + Layout mainLayout = new VerticalLayout(); + addComponent(mainLayout); + setCompositionRoot(mainLayout); + + Component table = new Table(); + table.setWidth("100%"); + table.setId(TABLE); + mainLayout.addComponent(table); + } + } + + @Override + protected String getTestDescription() { + return "The size calculations fails in IE8 when undefined size table is inside a tabsheet"; + } + + @Override + protected Integer getTicketNumber() { + return 12687; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java new file mode 100644 index 0000000000..29fc5a2e52 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2013 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.components.table; + +import static com.vaadin.tests.components.table.TableSizeInTabsheet.TABLE; +import static com.vaadin.tests.components.table.TableSizeInTabsheet.TABSHEET; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TableSizeInTabsheetTest extends MultiBrowserTest { + + private static final String TABSHEET_CONTENT_STYLENAME = "v-tabsheet-content"; + + @Test + public void testTabsheetContentHasTheSameHeightAsTable() { + openTestURL(); + int tableHeight = getTableHeigth(); + int tabSheetContentHeight = getTableSheetContentHeight(); + + Assert.assertEquals(tableHeight, tabSheetContentHeight); + } + + private int getTableHeigth() { + return vaadinElementById(TABLE).getSize().getHeight(); + } + + private int getTableSheetContentHeight() { + WebElement tabsheetContent = vaadinElementById(TABSHEET).findElement( + By.className(TABSHEET_CONTENT_STYLENAME)); + return tabsheetContent.getSize().getHeight(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltip.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltip.java new file mode 100644 index 0000000000..02482b7049 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltip.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2013 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.components.tabsheet; + +import com.vaadin.server.UserError; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.Tab; + +public class TabSheetErrorTooltip extends AbstractTestUI { + + private TabSheet tabSheet = new TabSheet(); + private int tabCount = 0; + + @Override + protected void setup(VaadinRequest request) { + + addTab(); + addTab().setComponentError(new UserError("Error!")); + addTab().setDescription("This is a tab"); + + Tab t = addTab(); + t.setComponentError(new UserError("Error!")); + t.setDescription("This tab has both an error and a description"); + + setContent(tabSheet); + } + + private Tab addTab() { + tabCount++; + Label contents = new Label("Contents for tab " + tabCount); + return tabSheet.addTab(contents, "Tab " + tabCount); + } + + @Override + protected String getTestDescription() { + return "TabSheet Tabs should display component error tooltips when expected"; + } + + @Override + protected Integer getTicketNumber() { + return 12802; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java new file mode 100644 index 0000000000..88bc23d12b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 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.components.tabsheet; + +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabSheetErrorTooltipTest extends MultiBrowserTest { + + @Test + public void checkTooltips() throws IOException { + openTestURL(); + + testBenchElement(getTab(0)).showTooltip(); + assertNoTooltip(); + + testBenchElement(getTab(1)).showTooltip(); + assertErrorMessage("Error!"); + assertTooltip(""); + + testBenchElement(getTab(2)).showTooltip(); + assertErrorMessage(""); + assertTooltip("This is a tab"); + + testBenchElement(getTab(3)).showTooltip(); + assertErrorMessage("Error!"); + assertTooltip("This tab has both an error and a description"); + } + + private WebElement getTab(int index) { + return vaadinElement("/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[" + + index + "]/domChild[0]"); + } + + private WebElement getTooltip() { + return getDriver().findElement( + By.xpath("//div[@class='v-tooltip-text']")); + } + + private WebElement getErrorMessage() { + return getDriver().findElement( + By.xpath("//div[@class='v-errormessage']")); + } + + private void assertTooltip(String tooltip) { + Assert.assertEquals(tooltip, getTooltip().getText()); + } + + private void assertErrorMessage(String message) { + Assert.assertEquals(message, getErrorMessage().getText()); + } + + private void assertNoTooltip() { + try { + getTooltip(); + } catch (NoSuchElementException e) { + return; + } + Assert.fail("Tooltip exists"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindow.java b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindow.java new file mode 100644 index 0000000000..6347ff9a76 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindow.java @@ -0,0 +1,66 @@ +/* + * Copyright 2000-2013 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.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class ComboboxScrollableWindow extends AbstractTestUI { + + static final String WINDOW_ID = "window"; + static final String COMBOBOX_ID = "combobox"; + + @Override + protected void setup(VaadinRequest request) { + + Window w = new Window(); + w.setId(WINDOW_ID); + w.setWidth("300px"); + w.setHeight("300px"); + w.center(); + + VerticalLayout content = new VerticalLayout(); + w.setContent(content); + content.setHeight("1000px"); + ComboBox cb = new ComboBox(); + cb.setId(COMBOBOX_ID); + content.addComponent(cb); + content.setComponentAlignment(cb, Alignment.BOTTOM_CENTER); + + addWindow(w); + + } + + @Override + protected String getTestDescription() { + return "The combo box in the bottom of the scrollable window should remain visible when it is clicked."; + } + + @Override + protected Integer getTicketNumber() { + return 12736; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java new file mode 100644 index 0000000000..665e175f2c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 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.components.window; + +import static com.vaadin.tests.components.window.ComboboxScrollableWindow.COMBOBOX_ID; +import static com.vaadin.tests.components.window.ComboboxScrollableWindow.WINDOW_ID; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class ComboboxScrollableWindowTest extends MultiBrowserTest { + + @Test + public void testWindowScrollbars() throws Exception { + openTestURL(); + com.vaadin.testbench.Parameters + .setScreenshotComparisonCursorDetection(true); + + WebElement window = driver.findElement(By.id(WINDOW_ID)); + WebElement scrollableElement = window.findElement(By + .className("v-scrollable")); + TestBenchElementCommands scrollable = testBenchElement(scrollableElement); + scrollable.scroll(1000); + WebElement comboBox = driver.findElement(By.id(COMBOBOX_ID)); + WebElement selectButton = driver.findElement(By + .className("v-filterselect-button")); + selectButton.click(); + + // Wait for the browser before taking a screenshot + Thread.sleep(1000); + compareScreen(getScreenshotBaseName()); + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java new file mode 100644 index 0000000000..e0bc0d9471 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.server.VaadinRequest; +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.Window; + +@SuppressWarnings("serial") +public class WindowMoveListener extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + Window w = new Window("Caption"); + w.setId("testwindow"); + w.setHeight("100px"); + w.setWidth("100px"); + w.setPositionX(100); + w.setPositionY(100); + addWindow(w); + + Button b = new Button(); + b.setId("testbutton"); + addComponent(b); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + for (Window window : getWindows()) { + window.setPositionX(100); + window.setPositionY(100); + } + } + }); + + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Tests that windows send their updated position " + + "to server-side after being moved by user"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12885; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java new file mode 100644 index 0000000000..3ea3b719c0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java @@ -0,0 +1,50 @@ +package com.vaadin.tests.components.window; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Action; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class WindowMoveListenerTest extends MultiBrowserTest { + + @Test + public void testWindowRepositioning() throws Exception { + openTestURL(); + + WebElement window = getDriver().findElement(By.id("testwindow")); + WebElement button = getDriver().findElement(By.id("testbutton")); + + // I'd loved to use the header, but that doesn't work. Footer works + // fine, though :) + WebElement windowHeader = getDriver().findElement( + By.className("v-window-footer")); + + Point winPos = window.getLocation(); + + // move window + Action a = new Actions(driver).clickAndHold(windowHeader) + .moveByOffset(100, 100).release().build(); + a.perform(); + + assertNotEquals("Window was not dragged correctly.", winPos.x, + window.getLocation().x); + assertNotEquals("Window was not dragged correctly.", winPos.y, + window.getLocation().y); + + // re-set window + button.click(); + + assertEquals("Window was not re-positioned correctly.", winPos.x, + window.getLocation().x); + assertEquals("Window was not re-positioned correctly.", winPos.y, + window.getLocation().y); + + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java index 221680be11..f55867c464 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java @@ -124,6 +124,13 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button5 = new Button("Test remove row 0"); final Button button6 = new Button("Test remove comp row3"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + button5.setId("testButton5"); + button6.setId("testButton6"); + baseLayout.addComponent(button1); baseLayout.addComponent(button2); baseLayout.addComponent(button3); @@ -223,6 +230,10 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button4 = new Button("undefined size+add, table"); glo.replaceComponent(x22, x22 = getTestTable()); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); baseLayout.addComponent(button1); baseLayout.addComponent(button2); @@ -287,6 +298,11 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button2 = new Button("set all cols expand 0.25"); final Button button3 = new Button("set row 0 expand 0.5"); final Button button4 = new Button("set row 3 expand 0.2"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + glo.setHeight("400px"); glo.replaceComponent(x22, x22 = getTestTable()); @@ -396,6 +412,11 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set fixed width and height 75%"); final Button button4 = new Button("Set size full"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + glo.replaceComponent(x22, x22 = getTestTable()); baseLayout.addComponent(button1); @@ -467,6 +488,11 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set margin off"); final Button button4 = new Button("Set spacing off"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + baseLayout.addComponent(button1); baseLayout.addComponent(button2); baseLayout.addComponent(button3); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java index 7a53a6583e..971205ccbb 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java @@ -123,7 +123,10 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button replaceButton = new Button("Test replace"); final Button moveButton = new Button("Test move"); final Button removeButton = new Button("Test remove"); - + addButton.setId("testButton1"); + replaceButton.setId("testButton2"); + moveButton.setId("testButton3"); + removeButton.setId("testButton4"); replaceButton.setEnabled(false); moveButton.setEnabled(false); removeButton.setEnabled(false); @@ -193,6 +196,10 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button smallerButton = new Button("200 px width"); final Button originalButton = new Button("undefined size+add"); + biggerButton.setId("testButton1"); + smallerButton.setId("testButton2"); + originalButton.setId("testButton3"); + baseLayout.addComponent(biggerButton); baseLayout.addComponent(smallerButton); baseLayout.addComponent(originalButton); @@ -257,6 +264,11 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set fixed width and height 75%"); final Button button4 = new Button("Set size full"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + baseLayout.addComponent(button1); baseLayout.addComponent(button2); baseLayout.addComponent(button3); @@ -332,6 +344,9 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button button1 = new Button("Expand to 1/undefined"); final Button button2 = new Button("Expand to 0.5/0.5"); final Button button3 = new Button("Expand to 0.75/0.25"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); baseLayout.addComponent(button1); baseLayout.addComponent(button2); @@ -438,6 +453,10 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button button2 = new Button("Set spacing on"); final Button button3 = new Button("Set margin off"); final Button button4 = new Button("Set spacing off"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); baseLayout.addComponent(button1); baseLayout.addComponent(button2); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html deleted file mode 100644 index 8408aba9fd..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html +++ /dev/null @@ -1,896 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>LayoutTesterApplication</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">LayoutTesterApplication</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.layouts.layouttester.LayoutTesterApplication?restartApplication</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>1</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>2</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>3</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>4</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>5</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>6</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>7</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>8</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>9</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>10</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>11</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>12</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>13</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>14</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>15</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>16</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>17</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>18</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>19</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>20</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>21</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>22</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>23</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>24</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>25</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>26</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>27</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>28</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VNativeSelect[0]/domChild[0]</td> - <td>label=class com.vaadin.ui.HorizontalLayout</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>29</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>30</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>31</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>32</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>33</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>34</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>35</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>36</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>37</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>38</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>39</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>40</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>41</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>42</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>43</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>44</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>45</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>46</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>47</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>48</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>49</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>50</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>51</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>52</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>53</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>54</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>55</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>56</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VNativeSelect[0]/domChild[0]</td> - <td>label=class com.vaadin.ui.GridLayout</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>57</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>58</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>59</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>60</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>61</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>62</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>63</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>64</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>65</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>66</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>67</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>68</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>69</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>70</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>71</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>72</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>73</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>74</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>75</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>76</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>77</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>78</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>79</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>80</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>81</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>82</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>83</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>84</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>85</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>86</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>87</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>88</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java index 72863895a1..5b68e04144 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java @@ -20,18 +20,20 @@ public class LayoutTesterApplication extends AbstractTestCase { Button nextButton = new Button("Next"); private int layoutIndex = -1; - private static final String[] layoutGetters = new String[] { - "getCaptionsTests", "getIconsTests", - "getRequiredErrorIndicatorsTests", "getAlignmentTests", - "getExpandRatiosTests", "getMarginSpacingTests", - "getComponentAddReplaceMoveTests", "getComponentSizingTests", - "getLayoutSizingTests" }; + static final String[] layoutGetters = new String[] { "getCaptionsTests", + "getIconsTests", "getRequiredErrorIndicatorsTests", + "getAlignmentTests", "getExpandRatiosTests", + "getMarginSpacingTests", "getComponentAddReplaceMoveTests", + "getComponentSizingTests", "getLayoutSizingTests" }; + public static final String NEXT_BUTTON_ID = "nextButton"; + private static final String LAYOUT_SELECT_ID = "layoutSelect"; private LegacyWindow mainWindow; private NativeSelect layoutSelector; @Override public void init() { + nextButton.setId(NEXT_BUTTON_ID); mainWindow = new LegacyWindow("LayoutTesterApplication"); setMainWindow(mainWindow); nextLayout(); @@ -112,6 +114,7 @@ public class LayoutTesterApplication extends AbstractTestCase { private NativeSelect getLayoutTypeSelect() { if (layoutSelector == null) { layoutSelector = new NativeSelect(); + layoutSelector.setId(LAYOUT_SELECT_ID); layoutSelector.addItem(VerticalLayout.class); layoutSelector.addItem(HorizontalLayout.class); layoutSelector.addItem(GridLayout.class); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java new file mode 100644 index 0000000000..33197613dc --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java @@ -0,0 +1,137 @@ +/* + * Copyright 2000-2013 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.layouts.layouttester; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; + +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.VerticalLayout; + +public class LayoutTesterApplicationTest extends MultiBrowserTest { + Map<String, Integer> numberOfSubTests = new HashMap<String, Integer>(); + private Set<String> tableOrIconsTests = new HashSet<String>(); + + { + numberOfSubTests.put("getExpandRatiosTests", 3); + numberOfSubTests.put("getLayoutSizingTests", 4); + numberOfSubTests.put("getComponentAddReplaceMoveTests", 4); + numberOfSubTests.put("getMarginSpacingTests", 4); + numberOfSubTests.put("getComponentSizingTests", 3); + + tableOrIconsTests.add("getComponentSizingTests"); + tableOrIconsTests.add("getExpandRatiosTests"); + tableOrIconsTests.add("getLayoutSizingTests"); + tableOrIconsTests.add("getMarginSpacingTests"); + tableOrIconsTests.add("getIconsTests"); + + } + + @Test + public void verticalLayout() throws Exception { + openTestURL(); + runTest(VerticalLayout.class); + } + + @Test + public void horizontalLayout() throws Exception { + openTestURL(); + runTest(HorizontalLayout.class); + } + + @Test + public void gridLayout() throws Exception { + numberOfSubTests.put("getComponentAddReplaceMoveTests", 6); + numberOfSubTests.put("getComponentSizingTests", 4); + numberOfSubTests.put("getExpandRatiosTests", 4); + + openTestURL(); + runTest(GridLayout.class); + } + + private void runTest(Class<?> layoutClass) throws Exception { + new Select(vaadinElementById("layoutSelect").findElement( + By.xpath("select"))) + .selectByVisibleText(layoutClass.toString()); + focusElementWithId("nextButton"); + + for (String subTest : LayoutTesterApplication.layoutGetters) { + compareScreen(subTest); + Integer subTests = numberOfSubTests.get(subTest); + if (subTests != null) { + for (int i = 1; i <= subTests; i++) { + clickAndCompareScreen(subTest, "testButton" + i); + } + } + getNextButton().click(); + } + + } + + /** + * @param elementId + * the id of the element to focus + */ + private void focusElementWithId(String elementId) { + // This should really be in TestBench + ((JavascriptExecutor) getDriver()) + .executeScript("document.getElementById('" + elementId + + "').focus()"); + } + + /** + * Clicks the button with the given id and compares the result to a + * screenshot named 'screenshotPrefix'-buttonCaption. + * + * @param screenshotPrefix + * @param buttonId + * @throws Exception + */ + private void clickAndCompareScreen(String screenshotPrefix, String buttonId) + throws Exception { + WebElement button = vaadinElementById(buttonId); + button.click(); + if (needsDelayToStabilize(screenshotPrefix)) { + // Table does some extra layout phase and TestBench does not always + // take this into account, grabbing screenshots before the layout + // phase is done (see #12866). + sleep(200); + } + compareScreen(screenshotPrefix + "-" + sanitize(button.getText())); + } + + private boolean needsDelayToStabilize(String screenshotPrefix) { + return tableOrIconsTests.contains(screenshotPrefix); + } + + private String sanitize(String text) { + return text.replace("%", "pct").replaceAll("[^a-zA-Z0-9]", "-"); + } + + private WebElement getNextButton() { + return vaadinElementById(LayoutTesterApplication.NEXT_BUTTON_ID); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java index 7764589ff7..04cee2d68d 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java @@ -127,6 +127,10 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button replaceButton = new Button("Test replace"); final Button moveButton = new Button("Test move"); final Button removeButton = new Button("Test remove"); + addButton.setId("testButton1"); + replaceButton.setId("testButton2"); + moveButton.setId("testButton3"); + removeButton.setId("testButton4"); replaceButton.setEnabled(false); moveButton.setEnabled(false); @@ -196,7 +200,9 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button biggerButton = new Button("full size"); final Button smallerButton = new Button("200 px width"); final Button originalButton = new Button("undefined size and add"); - + biggerButton.setId("testButton1"); + smallerButton.setId("testButton2"); + originalButton.setId("testButton3"); vlo.addComponent(biggerButton); vlo.addComponent(smallerButton); vlo.addComponent(originalButton); @@ -265,6 +271,11 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set fixed width and height 75%"); final Button button4 = new Button("Set size full"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + vlo.addComponent(button1); vlo.addComponent(button2); vlo.addComponent(button3); @@ -344,8 +355,11 @@ public class VerticalLayoutTests extends AbstractLayoutTests { c2.setSizeFull(); final Button button1 = new Button("Expand to 1/undefined"); + button1.setId("testButton1"); final Button button2 = new Button("Expand to 0.5/0.5"); + button2.setId("testButton2"); final Button button3 = new Button("Expand to 0.75/0.25"); + button3.setId("testButton3"); vlo.addComponent(button1); vlo.addComponent(button2); @@ -460,6 +474,10 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button button2 = new Button("Set spacing on"); final Button button3 = new Button("Set margin off"); final Button button4 = new Button("Set spacing off"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); vlo.addComponent(button1); vlo.addComponent(button2); diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java index d6c45a2ed0..8e8f418c5f 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPush.java +++ b/uitest/src/com/vaadin/tests/push/BasicPush.java @@ -30,6 +30,16 @@ import com.vaadin.ui.Label; @Push public class BasicPush extends AbstractTestUI { + public static final String CLIENT_COUNTER_ID = "clientCounter"; + + public static final String STOP_TIMER_ID = "stopTimer"; + + public static final String START_TIMER_ID = "startTimer"; + + public static final String SERVER_COUNTER_ID = "serverCounter"; + + public static final String INCREMENT_BUTTON_ID = "incrementCounter"; + private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0); @@ -48,15 +58,19 @@ public class BasicPush extends AbstractTestUI { */ Label lbl = new Label(counter); lbl.setCaption("Client counter (click 'increment' to update):"); + lbl.setId(CLIENT_COUNTER_ID); addComponent(lbl); - addComponent(new Button("Increment", new Button.ClickListener() { + Button incrementButton = new Button("Increment", + new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - counter.setValue(counter.getValue() + 1); - } - })); + @Override + public void buttonClick(ClickEvent event) { + counter.setValue(counter.getValue() + 1); + } + }); + incrementButton.setId(INCREMENT_BUTTON_ID); + addComponent(incrementButton); spacer(); @@ -65,33 +79,37 @@ public class BasicPush extends AbstractTestUI { */ lbl = new Label(counter2); lbl.setCaption("Server counter (updates each 3s by server thread) :"); + lbl.setId(SERVER_COUNTER_ID); addComponent(lbl); - addComponent(new Button("Start timer", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - counter2.setValue(0); - if (task != null) { - task.cancel(); - } - task = new TimerTask() { + Button startTimer = new Button("Start timer", + new Button.ClickListener() { @Override - public void run() { - access(new Runnable() { + public void buttonClick(ClickEvent event) { + counter2.setValue(0); + if (task != null) { + task.cancel(); + } + task = new TimerTask() { + @Override public void run() { - counter2.setValue(counter2.getValue() + 1); + access(new Runnable() { + @Override + public void run() { + counter2.setValue(counter2.getValue() + 1); + } + }); } - }); + }; + timer.scheduleAtFixedRate(task, 3000, 3000); } - }; - timer.scheduleAtFixedRate(task, 3000, 3000); - } - })); + }); + startTimer.setId(START_TIMER_ID); + addComponent(startTimer); - addComponent(new Button("Stop timer", new Button.ClickListener() { + Button stopTimer = new Button("Stop timer", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (task != null) { @@ -99,7 +117,9 @@ public class BasicPush extends AbstractTestUI { task = null; } } - })); + }); + stopTimer.setId(STOP_TIMER_ID); + addComponent(stopTimer); } @Override diff --git a/uitest/src/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java index 57af8524bc..ef40ae09dc 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPushTest.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java @@ -19,6 +19,7 @@ import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; +import com.vaadin.tests.tb3.AbstractTB3Test; import com.vaadin.tests.tb3.MultiBrowserTest; public abstract class BasicPushTest extends MultiBrowserTest { @@ -30,15 +31,13 @@ public abstract class BasicPushTest extends MultiBrowserTest { // Test client initiated push Assert.assertEquals(0, getClientCounter()); getIncrementButton().click(); - Assert.assertEquals( - "Client counter not incremented by button click", 1, - getClientCounter()); + Assert.assertEquals("Client counter not incremented by button click", + 1, getClientCounter()); getIncrementButton().click(); getIncrementButton().click(); getIncrementButton().click(); - Assert.assertEquals( - "Four clicks should have incremented counter to 4", 4, - getClientCounter()); + Assert.assertEquals("Four clicks should have incremented counter to 4", + 4, getClientCounter()); // Test server initiated push getServerCounterStartButton().click(); @@ -63,30 +62,47 @@ public abstract class BasicPushTest extends MultiBrowserTest { } private int getServerCounter() { - return Integer.parseInt(getServerCounterElement().getText()); + return getServerCounter(this); } private int getClientCounter() { - return Integer.parseInt(getClientCounterElement().getText()); + return getClientCounter(this); } - private WebElement getServerCounterElement() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]"); + public static int getClientCounter(AbstractTB3Test t) { + WebElement clientCounterElem = t + .vaadinElementById(BasicPush.CLIENT_COUNTER_ID); + return Integer.parseInt(clientCounterElem.getText()); } - private WebElement getServerCounterStartButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]"); + private WebElement getIncrementButton() { + return getIncrementButton(this); } private WebElement getServerCounterStopButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]"); + return getServerCounterStopButton(this); } - private WebElement getIncrementButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]"); + private WebElement getServerCounterStartButton() { + return getServerCounterStartButton(this); + } + + public static int getServerCounter(AbstractTB3Test t) { + WebElement serverCounterElem = t + .vaadinElementById(BasicPush.SERVER_COUNTER_ID); + return Integer.parseInt(serverCounterElem.getText()); } - private WebElement getClientCounterElement() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]"); + public static WebElement getServerCounterStartButton(AbstractTB3Test t) { + return t.vaadinElementById(BasicPush.START_TIMER_ID); } + + public static WebElement getServerCounterStopButton(AbstractTB3Test t) { + return t.vaadinElementById(BasicPush.STOP_TIMER_ID); + } + + public static WebElement getIncrementButton(AbstractTB3Test t) { + return t.vaadinElementById(BasicPush.INCREMENT_BUTTON_ID); + } + }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java index 50dab43667..ac37e75fea 100644 --- a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java +++ b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java @@ -1,74 +1,19 @@ package com.vaadin.tests.push; -import static org.junit.Assert.assertEquals; - import java.util.Date; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.openqa.selenium.WebElement; - import com.vaadin.server.VaadinRequest; import com.vaadin.shared.communication.PushMode; import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.UIDetachedException; public class EnableDisablePush extends AbstractTestUI { - public static class EnableDisablePushTest extends MultiBrowserTest { - @Test - public void testEnablePushWhenUsingPolling() throws Exception { - openTestURL(); - - assertEquals("1. Push enabled", getLogRow(0)); - - getDisablePushButton().click(); - assertEquals("3. Push disabled", getLogRow(0)); - - getEnablePollButton().click(); - assertEquals("5. Poll enabled", getLogRow(0)); - - getEnablePushButton().click(); - assertEquals("7. Push enabled", getLogRow(0)); - - getDisablePollButton().click(); - assertEquals("9. Poll disabled", getLogRow(0)); - - getDisablePushButtonAndReenableFromBackground().click(); - Thread.sleep(2500); - assertEquals("16. Polling disabled, push enabled", getLogRow(0)); - - getDisablePushButton().click(); - assertEquals("18. Push disabled", getLogRow(0)); - } - - private WebElement getDisablePushButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]"); - } - - private WebElement getEnablePushButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]"); - } - - private WebElement getDisablePollButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]"); - } - - private WebElement getEnablePollButton() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]"); - } - - private WebElement getDisablePushButtonAndReenableFromBackground() { - return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]"); - } - - } - private int c = 0; private Log log = new Log(15); diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePushTest.java b/uitest/src/com/vaadin/tests/push/EnableDisablePushTest.java new file mode 100644 index 0000000000..275b6d5b53 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/EnableDisablePushTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2013 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.push; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class EnableDisablePushTest extends MultiBrowserTest { + @Test + public void testEnablePushWhenUsingPolling() throws Exception { + openTestURL(); + + assertEquals("1. Push enabled", getLogRow(0)); + + getDisablePushButton().click(); + assertEquals("3. Push disabled", getLogRow(0)); + + getEnablePollButton().click(); + assertEquals("5. Poll enabled", getLogRow(0)); + + getEnablePushButton().click(); + assertEquals("7. Push enabled", getLogRow(0)); + + getDisablePollButton().click(); + assertEquals("9. Poll disabled", getLogRow(0)); + + getDisablePushButtonAndReenableFromBackground().click(); + Thread.sleep(2500); + assertEquals("16. Polling disabled, push enabled", getLogRow(0)); + + getDisablePushButton().click(); + assertEquals("18. Push disabled", getLogRow(0)); + } + + private WebElement getDisablePushButton() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]"); + } + + private WebElement getEnablePushButton() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]"); + } + + private WebElement getDisablePollButton() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]"); + } + + private WebElement getEnablePollButton() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]"); + } + + private WebElement getDisablePushButtonAndReenableFromBackground() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/PushLargeData.java b/uitest/src/com/vaadin/tests/push/PushLargeData.java index 8ad005df81..3b72424b32 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeData.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeData.java @@ -34,6 +34,18 @@ import com.vaadin.ui.UI; public abstract class PushLargeData extends AbstractTestUIWithLog { + // 1MB + static final int DEFAULT_SIZE_BYTES = 1000 * 1000; + + // Every other second + static final int DEFAULT_DELAY_MS = 2000; + + // 20 MB is enough for streaming to reconnect + static final int DEFAULT_DATA_TO_PUSH = 20 * 1000 * 1000; + + static final int DEFAULT_DURATION_MS = DEFAULT_DATA_TO_PUSH + / DEFAULT_SIZE_BYTES * DEFAULT_DELAY_MS; + private Label dataLabel = new Label(); private final ExecutorService executor = Executors @@ -49,9 +61,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { final TextField duration = new TextField("Duration (ms)"); duration.setConverter(Integer.class); - dataSize.setValue((1000 * 1000) + ""); - interval.setValue(2000 + ""); - duration.setValue(40 * 1000 + ""); + dataSize.setValue(DEFAULT_SIZE_BYTES + ""); + interval.setValue(DEFAULT_DELAY_MS + ""); + duration.setValue(DEFAULT_DURATION_MS + ""); addComponent(dataSize); addComponent(interval); @@ -114,7 +126,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { @Override public void run() { PushLargeData ui = (PushLargeData) UI.getCurrent(); - ui.getDataLabel().setValue( + // Using description as it is not rendered to the DOM + // immediately + ui.getDataLabel().setDescription( System.currentTimeMillis() + ": " + data); ui.log("Package " + idx + " pushed"); } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java index 464cbcc757..7706aa90c6 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java @@ -15,15 +15,19 @@ */ package com.vaadin.tests.push; +import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; +@Push(transport = Transport.STREAMING) public class PushLargeDataStreaming extends PushLargeData { @Override protected void setup(VaadinRequest request) { super.setup(request); getPushConfiguration().setTransport(Transport.STREAMING); - getPushConfiguration().setFallbackTransport(Transport.STREAMING); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java index c716a6fc7e..8f10f0fbba 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java @@ -19,12 +19,12 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; -import com.vaadin.tests.tb3.WebsocketTest; +import com.vaadin.tests.tb3.MultiBrowserTest; -public class PushLargeDataStreamingTest extends WebsocketTest { +public class PushLargeDataStreamingTest extends MultiBrowserTest { @Test - public void testWebsocketLargeData() { + public void testStreamingLargeData() { openTestURL(); // Without this there is a large chance that we will wait for all pushes @@ -39,17 +39,23 @@ public class PushLargeDataStreamingTest extends WebsocketTest { } private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + String logRow0Id = "Log_row_0"; By logRow0 = vaadinLocatorById(logRow0Id); vaadinElementById("startButton").click(); - waitUntil(ExpectedConditions.not(ExpectedConditions - .textToBePresentInElement(logRow0, "Push complete"))); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package ")); - // Pushes each 2000ms for 40s - sleep(40000); + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + // Wait until push is actually done waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, "Push complete")); } + } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java index 974dc880f9..4115a825d1 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java @@ -19,14 +19,15 @@ package com.vaadin.tests.push; import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; -@Push +@Push(transport = Transport.WEBSOCKET) public class PushLargeDataWebsocket extends PushLargeData { @Override protected void setup(VaadinRequest request) { super.setup(request); - getPushConfiguration().setTransport(Transport.WEBSOCKET); - getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java index 83f9efc8dd..70a94f743e 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java @@ -39,17 +39,21 @@ public class PushLargeDataWebsocketTest extends WebsocketTest { } private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + String logRow0Id = "Log_row_0"; By logRow0 = vaadinLocatorById(logRow0Id); - testBench(driver).waitForVaadin(); vaadinElementById("startButton").click(); - waitUntil(ExpectedConditions.not(ExpectedConditions - .textToBePresentInElement(logRow0, "Push complete"))); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package")); - // Pushes each 2000ms for 40s - sleep(40000); + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + // Wait until push is actually done waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, "Push complete")); } diff --git a/uitest/src/com/vaadin/tests/push/PushReconnectTest.java b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java new file mode 100644 index 0000000000..76a0b547da --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java @@ -0,0 +1,164 @@ +/* + * Copyright 2000-2013 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.push; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; + +public abstract class PushReconnectTest extends MultiBrowserTestWithProxy { + + @Test + public void testShortDisconnect() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + } + + @Test + public void testUserActionWhileDisconnectedWithDelay() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Assert.assertEquals(0, getClientCounter()); + getIncrementClientCounterButton().click(); + // No change while disconnected + Assert.assertEquals(0, getClientCounter()); + // Firefox sends extra onopen calls after a while, which breaks + // everything + Thread.sleep(10000); + connectProxy(); + waitUntilServerCounterChanges(); + // The change should have appeared when reconnected + Assert.assertEquals(1, getClientCounter()); + } + + @Test + public void testUserActionWhileDisconnected() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Assert.assertEquals(0, getClientCounter()); + getIncrementClientCounterButton().click(); + // No change while disconnected + Assert.assertEquals(0, getClientCounter()); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + // The change should have appeared when reconnected + Assert.assertEquals(1, getClientCounter()); + + // IE has problems with another reconnect + disconnectProxy(); + getIncrementClientCounterButton().click(); + Assert.assertEquals(1, getClientCounter()); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + Assert.assertEquals(2, getClientCounter()); + } + + @Test + public void testLongDisconnect() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Thread.sleep(12000); + connectProxy(); + waitUntilServerCounterChanges(); + } + + @Test + public void testReallyLongDisconnect() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Thread.sleep(120000); + connectProxy(); + waitUntilServerCounterChanges(); + } + + @Test + public void testMultipleDisconnects() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + for (int i = 0; i < 5; i++) { + disconnectProxy(); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + } + } + + @Test + public void testMultipleQuickReconnects() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + for (int i = 0; i < 50; i++) { + disconnectProxy(); + Thread.sleep(100); + connectProxy(); + Thread.sleep(100); + } + waitUntilServerCounterChanges(); + waitUntilServerCounterChanges(); + } + + private int getClientCounter() { + return BasicPushTest.getClientCounter(this); + } + + private WebElement getIncrementClientCounterButton() { + return BasicPushTest.getIncrementButton(this); + } + + private void waitUntilServerCounterChanges() { + final int counter = BasicPushTest.getServerCounter(this); + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest.getServerCounter(PushReconnectTest.this) > counter; + } + }, 30); + } + + private void startTimer() { + BasicPushTest.getServerCounterStartButton(this).click(); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java b/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java new file mode 100755 index 0000000000..24dfdd8ba1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2013 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.push; + +public class StreamingReconnectTest extends PushReconnectTest { + + @Override + protected Class<?> getUIClass() { + return BasicPushStreaming.class; + } + +} diff --git a/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.java b/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.java new file mode 100644 index 0000000000..075a18c0e7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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.push; + +import java.util.List; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class WebsocketReconnectTest extends PushReconnectTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return WebsocketTest.getWebsocketBrowsers(); + } + + @Override + protected Class<?> getUIClass() { + return BasicPushWebsocket.class; + } + +} diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 712ef94397..d4eed99f19 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -19,7 +19,6 @@ package com.vaadin.tests.tb3; import java.net.URL; import java.util.Collections; import java.util.List; -import java.util.logging.Logger; import org.junit.After; import org.junit.Before; @@ -197,7 +196,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * * @return The port teh test is running on, by default 8888 */ - protected abstract String getDeploymentPort(); + protected abstract int getDeploymentPort(); /** * Produces a collection of browsers to run the test on. This method is @@ -306,18 +305,31 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } /** - * Waits a short while for the given condition to become true. Use e.g. as + * Waits up to 10s for the given condition to become true. Use e.g. as * {@link #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))} * * @param condition * the condition to wait for to become true */ protected void waitUntil(ExpectedCondition<Boolean> condition) { - new WebDriverWait(driver, 10).until(condition); + waitUntil(condition, 10); } /** - * Waits a short while for the given condition to become false. Use e.g. as + * Waits the given number of seconds for the given condition to become true. + * Use e.g. as {@link + * #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))} + * + * @param condition + * the condition to wait for to become true + */ + protected void waitUntil(ExpectedCondition<Boolean> condition, + long timeoutInSeconds) { + new WebDriverWait(driver, timeoutInSeconds).until(condition); + } + + /** + * Waits up to 10s for the given condition to become false. Use e.g. as * {@link #waitUntilNot(ExpectedConditions.textToBePresentInElement(by, * text))} * @@ -325,7 +337,25 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * the condition to wait for to become false */ protected void waitUntilNot(ExpectedCondition<Boolean> condition) { - new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition)); + waitUntilNot(condition, 10); + } + + /** + * Waits the given number of seconds for the given condition to become + * false. Use e.g. as {@link + * #waitUntilNot(ExpectedConditions.textToBePresentInElement(by, text))} + * + * @param condition + * the condition to wait for to become false + */ + protected void waitUntilNot(ExpectedCondition<Boolean> condition, + long timeoutInSeconds) { + waitUntil(ExpectedConditions.not(condition), timeoutInSeconds); + } + + protected void waitForElementToBePresent(By by) { + waitUntil(ExpectedConditions.not(ExpectedConditions + .invisibilityOfElementLocated(by))); } /** @@ -476,14 +506,6 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } } catch (Exception e) { } - Class<?> enclosingClass = getClass().getEnclosingClass(); - if (enclosingClass != null) { - if (UI.class.isAssignableFrom(enclosingClass)) { - Logger.getLogger(getClass().getName()) - .severe("Test is an static inner class to the UI. This will no longer be supported in the future. The test should be named UIClassTest and reside in the same package as the UI"); - return enclosingClass; - } - } throw new RuntimeException( "Could not determine UI class. Ensure the test is named UIClassTest and is in the same package as the UIClass"); } @@ -645,6 +667,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ public static DesiredCapabilities safari(int version) { DesiredCapabilities c = DesiredCapabilities.safari(); + c.setPlatform(Platform.MAC); c.setVersion("" + version); return c; } diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index 040d0156a3..e8a974343b 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -40,7 +40,7 @@ import org.openqa.selenium.remote.DesiredCapabilities; */ public abstract class MultiBrowserTest extends PrivateTB3Configuration { - public static final int TESTED_SAFARI_VERSION = 6; + public static final int TESTED_SAFARI_VERSION = 7; public static final int TESTED_CHROME_VERSION = 29; public static final int TESTED_FIREFOX_VERSION = 24; @@ -52,7 +52,7 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration { allBrowsers.add(BrowserUtil.ie(11)); allBrowsers.add(BrowserUtil.firefox(TESTED_FIREFOX_VERSION)); // Uncomment once we have the capability to run on Safari 6 - // allBrowsers.add(safari(TESTED_SAFARI_VERSION)); + // allBrowsers.add(BrowserUtil.safari(TESTED_SAFARI_VERSION)); allBrowsers.add(BrowserUtil.chrome(TESTED_CHROME_VERSION)); // Re-enable this when it is possible to run on a modern Opera version // (15+) diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java new file mode 100755 index 0000000000..0bb76889a0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java @@ -0,0 +1,106 @@ +/* + * Copyright 2000-2013 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.tb3; + +import java.io.File; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.After; +import org.junit.Before; + +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.Session; + +public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { + + private static AtomicInteger availablePort = new AtomicInteger(2000); + private Session proxySession; + private Integer proxyPort = null; + private JSch jsch; + private static String sshDir = System.getProperty("user.home") + "/.ssh/"; + private String[] publicKeys = new String[] { + System.getProperty("sshkey.file"), sshDir + "id_rsa", + sshDir + "id_dsa", sshDir + "id_rsa2" }; + + @Before + public void setupInitialProxy() throws JSchException { + connectProxy(); + } + + @After + public void teardownProxy() { + disconnectProxy(); + } + + protected Integer getProxyPort() { + if (proxyPort == null) { + // Assumes we can use any port >= 2000 + proxyPort = availablePort.addAndGet(1); + } + return proxyPort; + } + + /** + * Disconnects the proxy if active + */ + protected void disconnectProxy() { + if (proxySession == null) { + return; + } + proxySession.disconnect(); + proxySession = null; + } + + /** + * Ensure the proxy is active. Does nothing if the proxy is already active. + */ + protected void connectProxy() throws JSchException { + if (proxySession != null) { + return; + } + + createProxy(getProxyPort()); + } + + private void createProxy(int proxyPort) throws JSchException { + if (jsch == null) { + jsch = new JSch(); + + String keyFile = null; + for (String publicKey : publicKeys) { + if (publicKey != null) { + if (new File(publicKey).exists()) { + keyFile = publicKey; + break; + } + } + } + jsch.addIdentity(keyFile); + } + proxySession = jsch.getSession("localhost"); + proxySession.setConfig("StrictHostKeyChecking", "no"); + proxySession.setPortForwardingL("0.0.0.0", proxyPort, + super.getDeploymentHostname(), super.getDeploymentPort()); + proxySession.connect(); + } + + @Override + protected String getBaseURL() { + return "http://" + getDeploymentHostname() + ":" + getProxyPort(); + } + +} diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index a2922af28f..caa35732d6 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -90,11 +90,12 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { } @Override - protected String getDeploymentPort() { - String port = getProperty(PORT_PROPERTY); + protected int getDeploymentPort() { + String portString = getProperty(PORT_PROPERTY); - if (port == null || "".equals(port)) { - port = "8888"; + int port = 8888; + if (portString != null && !"".equals(portString)) { + port = Integer.parseInt(portString); } return port; diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java index cbdae1a6c1..a51421d3d5 100644 --- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java @@ -31,7 +31,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.rules.TestRule; import org.junit.rules.TestWatcher; -import org.junit.runner.Description; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.remote.DesiredCapabilities; @@ -62,18 +61,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { String className = testClass.getSimpleName(); screenshotBaseName = className + "-" + testMethod; - } - - @Override - protected void failed(Throwable e, Description description) { - - // Notify Teamcity of failed test - if (!System.getProperty("teamcity.version", "").equals("")) { - System.out.print("##teamcity[publishArtifacts '"); - System.out.println(getScreenshotErrorBaseName() - + "* => screenshot-errors']"); - } - } + }; }; /** @@ -129,9 +117,28 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { // Matched one comparison but not all, remove all error images + // HTML files } else { - // All comparisons failed, keep the main error image + HTML - screenshotFailures.add(mainReference.getName()); - referenceToKeep = mainReference; + // Ensure we use the correct browser version (e.g. if running IE11 + // and only an IE 10 reference was available, then mainReference + // will be for IE 10, not 11) + String originalName = getScreenshotReferenceName(identifier); + File exactVersionFile = new File(originalName); + + if (!exactVersionFile.equals(mainReference)) { + // Rename png+html to have the correct version + File correctPng = getErrorFileFromReference(exactVersionFile); + File producedPng = getErrorFileFromReference(mainReference); + File correctHtml = htmlFromPng(correctPng); + File producedHtml = htmlFromPng(producedPng); + + producedPng.renameTo(correctPng); + producedHtml.renameTo(correctHtml); + referenceToKeep = exactVersionFile; + screenshotFailures.add(exactVersionFile.getName()); + } else { + // All comparisons failed, keep the main error image + HTML + screenshotFailures.add(mainReference.getName()); + referenceToKeep = mainReference; + } } // Remove all PNG/HTML files we no longer need (failed alternative @@ -140,10 +147,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { File failurePng = getErrorFileFromReference(failedAlternative); if (failedAlternative != referenceToKeep) { // Delete png + HTML - String htmlFileName = failurePng.getName().replace(".png", - ".html"); - File failureHtml = new File(failurePng.getParentFile(), - htmlFileName); + File failureHtml = htmlFromPng(failurePng); failurePng.delete(); failureHtml.delete(); @@ -152,6 +156,18 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { } /** + * Returns a new File which points to a .html file instead of the given .png + * file + * + * @param png + * @return + */ + private static File htmlFromPng(File png) { + return new File(png.getParentFile(), png.getName().replaceAll( + "\\.png$", ".png.html")); + } + + /** * * @param referenceFile * The reference image file (in the directory defined by |