diff options
Diffstat (limited to 'uitest/src/com')
25 files changed, 1353 insertions, 22 deletions
diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java b/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java new file mode 100644 index 0000000000..d8f7fface3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java @@ -0,0 +1,77 @@ +package com.vaadin.tests.application; + +import java.lang.reflect.Field; +import java.util.Map; +import java.util.Set; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ConnectorTracker; +import com.vaadin.ui.Window; + +public class ResynchronizeAfterAsyncRemoval extends AbstractTestUIWithLog { + + @Override + public void setup(VaadinRequest vaadinRequest) { + final Window window = new Window("Asynchronously removed window"); + window.center(); + + // The window will enqueue a non-immediate message reporting its current + // position. + addWindow(window); + + // Remove window immediately when the current response is sent + runAfterResponse(new Runnable() { + @Override + public void run() { + removeWindow(window); + } + }); + + // Clicking the button will trigger sending the window coordinates, but + // the window is already removed at that point. + addComponent(new Button("Am I dirty?", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log("Window removed: " + (window.getParent() == null)); + + boolean dirty = getUI().getConnectorTracker().isDirty( + event.getButton()); + log("Dirty: " + dirty); + } + })); + addComponent(new Button("Log unregistered connector count", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + logUnregisteredConnectorCount(); + } + })); + } + + private void logUnregisteredConnectorCount() { + int count = 0; + + Map<Integer, Set<String>> unregisterIdMap = getUnregisterIdMap(); + for (Set<String> set : unregisterIdMap.values()) { + count += set.size(); + } + log("syncId: " + getConnectorTracker().getCurrentSyncId()); + log("Unregistered connector count: " + count); + } + + @SuppressWarnings("unchecked") + private Map<Integer, Set<String>> getUnregisterIdMap() { + try { + ConnectorTracker tracker = getConnectorTracker(); + Field field = tracker.getClass().getDeclaredField( + "syncIdToUnregisteredConnectorIds"); + field.setAccessible(true); + return (Map<Integer, Set<String>>) field.get(tracker); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemovalTest.java b/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemovalTest.java new file mode 100644 index 0000000000..7f2dabe9f1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemovalTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.application; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ResynchronizeAfterAsyncRemovalTest extends SingleBrowserTest { + @Test + public void noResyncAfterAsyncRemoval() { + openTestURL(); + + $(ButtonElement.class).first().click(); + + Assert.assertEquals("Timing issue in the test?", + "1. Window removed: true", getLogRow(1)); + + Assert.assertEquals( + "Removing window should not cause button to be marked as dirty", + "2. Dirty: false", getLogRow(0)); + + ButtonElement logCountButton = $(ButtonElement.class).all().get(1); + logCountButton.click(); + + Assert.assertEquals("Sanity check", "3. syncId: 2", getLogRow(1)); + Assert.assertEquals("Sanity check", + "4. Unregistered connector count: 1", getLogRow(0)); + + logCountButton.click(); + + Assert.assertEquals("Sanity check", "5. syncId: 3", getLogRow(1)); + Assert.assertEquals( + "Unregistered connector map should have been cleared", + "6. Unregistered connector count: 0", getLogRow(0)); + } +} diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index dba055a65a..98b0f63ce1 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -205,4 +205,18 @@ public abstract class AbstractTestUI extends UI { return getSession().getBrowser(); } + /** + * Execute the provided runnable on the UI thread as soon as the current + * request has been sent. + */ + protected void runAfterResponse(final Runnable runnable) { + // Immediately start a thread that will start waiting for the session to + // get unlocked. + new Thread() { + @Override + public void run() { + accessSynchronously(runnable); + } + }.start(); + } } diff --git a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java new file mode 100644 index 0000000000..23dcddd8d0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.embedded; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.EmbeddedElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class EmbeddedAltTextTest extends MultiBrowserTest { + + @Before + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + waitForElementPresent(By.className("v-embedded")); + } + + @Test + public void testEmbeddedAltText() { + EmbeddedElement embedded = $(EmbeddedElement.class).first(); + + Assert.assertEquals("Alt text of the image", getAltText(embedded)); + assertHtmlSource("Alt text of the object"); + + $(ButtonElement.class).first().click(); + + Assert.assertEquals("New alt text of the image!", getAltText(embedded)); + assertHtmlSource("New alt text of the object!"); + } + + private void assertHtmlSource(String html) { + String pageSource = driver.getPageSource(); + Assert.assertTrue("Page source does not contain '" + html + "'", + pageSource.contains(html)); + } + + private String getAltText(EmbeddedElement embedded) { + return embedded.findElement(By.vaadin("/domChild[0]")).getAttribute( + "alt"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java index 3c5801e90e..28ffebcf56 100644 --- a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java +++ b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.java @@ -5,6 +5,7 @@ import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.server.ThemeResource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Embedded; +import com.vaadin.ui.Label; public class EmbeddedClickListenerRelativeCoordinates extends TestBase { @@ -12,17 +13,21 @@ public class EmbeddedClickListenerRelativeCoordinates extends TestBase { protected void setup() { Embedded e = new Embedded("Embedded caption", new ThemeResource( "../runo/icons/64/ok.png")); + final Label xLabel = new Label(); + xLabel.setId("x"); + final Label yLabel = new Label(); + yLabel.setId("y"); e.addListener(new ClickListener() { @Override public void click(ClickEvent event) { - getMainWindow() - .showNotification( - "" + event.getRelativeX() + ", " - + event.getRelativeY()); + xLabel.setValue("" + event.getRelativeX()); + yLabel.setValue("" + event.getRelativeY()); } }); addComponent(e); + addComponent(xLabel); + addComponent(yLabel); } @Override diff --git a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java new file mode 100644 index 0000000000..6bed0117f8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java @@ -0,0 +1,86 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.embedded; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.EmbeddedElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.parallel.BrowserUtil; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class EmbeddedClickListenerRelativeCoordinatesTest extends + MultiBrowserTest { + + @Before + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + waitForElementPresent(By.className("v-embedded")); + } + + @Test + public void testRelativeClick() { + clickAt(41, 22); + checkLocation(41, 22); + + clickAt(0, 0); + checkLocation(0, 0); + } + + private void clickAt(int x, int y) { + EmbeddedElement embedded = $(EmbeddedElement.class).first(); + + // IE8 consistently clicks two pixels left and above of the given + // position + if (isIE8()) { + x += 2; + y += 2; + } + embedded.click(x, y); + } + + private void checkLocation(int expectedX, int expectedY) { + LabelElement xLabel = $(LabelElement.class).id("x"); + LabelElement yLabel = $(LabelElement.class).id("y"); + + int x = Integer.parseInt(xLabel.getText()); + int y = Integer.parseInt(yLabel.getText()); + + Assert.assertEquals( + "Reported X-coordinate from Embedded does not match click location", + expectedX, x); + + // IE10 and IE11 sometimes click one pixel below the given position + int tolerance = isIE() ? 1 : 0; + Assert.assertTrue( + "Reported Y-coordinate from Embedded does not match click location", + Math.abs(expectedY - y) <= tolerance); + } + + private boolean isIE() { + return BrowserUtil.isIE(getDesiredCapabilities()); + } + + private boolean isIE8() { + return BrowserUtil.isIE8(getDesiredCapabilities()); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java new file mode 100644 index 0000000000..e6aff73532 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java @@ -0,0 +1,91 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import java.io.Serializable; + +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; + +public class GridCheckBoxDisplay extends AbstractTestUI { + + private static final long serialVersionUID = -5575892909354637168L; + private BeanItemContainer<Todo> todoContainer = new BeanItemContainer<Todo>( + Todo.class); + + @Override + protected void setup(VaadinRequest request) { + todoContainer.addBean(new Todo("Done task", true)); + todoContainer.addBean(new Todo("Not done", false)); + + Grid grid = new Grid(todoContainer); + grid.setSizeFull(); + + grid.setColumnOrder("done", "task"); + grid.getColumn("done").setWidth(75); + grid.getColumn("task").setExpandRatio(1); + + grid.setSelectionMode(Grid.SelectionMode.SINGLE); + + grid.setEditorEnabled(true); + grid.setImmediate(true); + + getLayout().addComponent(grid); + getLayout().setExpandRatio(grid, 1); + + } + + @Override + protected Integer getTicketNumber() { + return 16976; + } + + @Override + public String getDescription() { + return "Verify that checkbox state is correct for all items in editor"; + } + + public class Todo implements Serializable { + private static final long serialVersionUID = -5961103142478316018L; + + private boolean done; + private String task = ""; + + public Todo(String task, boolean done) { + this.task = task; + this.done = done; + } + + public boolean isDone() { + return done; + } + + public void setDone(boolean done) { + this.done = done; + } + + public String getTask() { + return task; + } + + public void setTask(String task) { + this.task = task; + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java new file mode 100644 index 0000000000..c430821534 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.SingleBrowserTest; + +@TestCategory("grid") +public class GridCheckBoxDisplayTest extends SingleBrowserTest { + @Test + public void testAddRow() { + openTestURL(); + + GridElement grid = $(GridElement.class).first(); + + Assert.assertEquals("First item had wrong value", "true", + grid.getCell(0, 0).getText()); + Assert.assertEquals("Second item had wrong value", "false", grid + .getCell(1, 0).getText()); + + // First edit false item and see that the CheckBox is unchecked + grid.getCell(1, 0).doubleClick(); + + CheckBoxElement checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("CheckBox was checked", "unchecked", + checkbox.getValue()); + + closeEditor(); + + // Edit true item and see that the CheckBox is checked + grid.getCell(0, 0).doubleClick(); + + checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("CheckBox was not checked.", "checked", + checkbox.getValue()); + + closeEditor(); + + // Edit false item and confirm that the CheckBox is unchecked again + grid.getCell(1, 0).doubleClick(); + + checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("CheckBox was checked", "unchecked", + checkbox.getValue()); + } + + /** + * Closes the grids editor using the cancel button + */ + private void closeEditor() { + findElement(By.className("v-grid-editor-cancel")).click(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java new file mode 100644 index 0000000000..1032378a2d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java @@ -0,0 +1,149 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.event.ItemClickEvent; +import com.vaadin.event.ItemClickEvent.ItemClickListener; +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.Component; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.DetailsGenerator; +import com.vaadin.ui.Grid.RowReference; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class GridDetailsDetach extends AbstractTestUI { + + private Grid currentGrid; + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setSizeFull(); + + Button button = new Button("Test"); + layout.addComponent(button); + layout.setExpandRatio(button, 0f); + + currentGrid = generateGrid(); + final VerticalLayout gridContainer = new VerticalLayout(); + gridContainer.addComponent(currentGrid); + + button.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + gridContainer.replaceComponent(currentGrid, new Label("Foo")); + } + }); + + layout.addComponent(new Button("Reattach Grid", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + gridContainer.removeAllComponents(); + gridContainer.addComponent(currentGrid); + } + })); + + layout.addComponent(gridContainer); + layout.setExpandRatio(gridContainer, 1f); + + addComponent(layout); + } + + private Grid generateGrid() { + BeanItemContainer<GridExampleBean> container = new BeanItemContainer<GridExampleBean>( + GridExampleBean.class); + for (int i = 0; i < 1000; i++) { + container.addItem(new GridExampleBean("Bean " + i, i * i, i / 10d)); + } + + final Grid grid = new Grid(container); + grid.setColumnOrder("name", "amount", "count"); + grid.setSizeFull(); + + grid.setDetailsGenerator(new DetailsGenerator() { + @Override + public Component getDetails(RowReference rowReference) { + final GridExampleBean bean = (GridExampleBean) rowReference + .getItemId(); + VerticalLayout layout = new VerticalLayout(new Label( + "Extra data for " + bean.getName())); + layout.setMargin(true); + return layout; + } + }); + + grid.addItemClickListener(new ItemClickListener() { + @Override + public void itemClick(ItemClickEvent event) { + Object itemId = event.getItemId(); + grid.setDetailsVisible(itemId, !grid.isDetailsVisible(itemId)); + } + }); + return grid; + } + + public class GridExampleBean { + + private String name; + + private int count; + + private double amount; + + public GridExampleBean() { + } + + public GridExampleBean(String name, int count, double amount) { + this.name = name; + this.count = count; + this.amount = amount; + } + + public String getName() { + return name; + } + + public int getCount() { + return count; + } + + public double getAmount() { + return amount; + } + + public void setName(String name) { + this.name = name; + } + + public void setCount(int count) { + this.count = count; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java new file mode 100644 index 0000000000..fc79fd1b68 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +@TestCategory("grid") +public class GridDetailsDetachTest extends MultiBrowserTest { + + @Test + public void testDetachGridWithDetailsOpen() { + setDebug(true); + openTestURL(); + + $(GridElement.class).first().getCell(3, 0).click(); + $(GridElement.class).first().getCell(5, 0).click(); + + assertNoErrorNotifications(); + + $(ButtonElement.class).first().click(); + + assertNoErrorNotifications(); + } + + @Test + public void testDetachAndReattachGridWithDetailsOpen() { + setDebug(true); + openTestURL(); + + $(GridElement.class).first().getCell(3, 0).click(); + $(GridElement.class).first().getCell(5, 0).click(); + + assertNoErrorNotifications(); + + $(ButtonElement.class).first().click(); + + assertNoErrorNotifications(); + + $(ButtonElement.class).get(1).click(); + + assertNoErrorNotifications(); + + List<WebElement> spacers = findElements(By.className("v-grid-spacer")); + Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size()); + Assert.assertEquals("Spacer content not visible", + "Extra data for Bean 3", spacers.get(0).getText()); + Assert.assertEquals("Spacer content not visible", + "Extra data for Bean 5", spacers.get(1).getText()); + } +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsWidthTest.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsWidthTest.java index 41838b427b..2def2d0279 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridDetailsWidthTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridDetailsWidthTest.java @@ -23,6 +23,7 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -66,4 +67,26 @@ public class GridDetailsWidthTest extends SingleBrowserTest { } } + @Test + public void testDetailsOnSort() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + + // Open a details rows + grid.getCell(0, 0).click(); + + GridCellElement cell = grid.getHeaderCell(0, 0); + cell.click(); + cell.click(); + + cell = grid.getCell(2, 0); + WebElement spacer = findElement(By.className("v-grid-spacer")); + Assert.assertEquals("Grid was not sorted correctly", "Hello 0", + cell.getText()); + Assert.assertEquals("Details row was not in correct location", cell + .getLocation().getY() + cell.getSize().getHeight(), spacer + .getLocation().getY()); + + } + } diff --git a/uitest/src/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java b/uitest/src/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java index 319cf3b8b8..4368fda158 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridSubPixelProblemWrappingTest.java @@ -15,30 +15,18 @@ */ package com.vaadin.tests.components.grid; -import java.util.List; - import org.junit.Assert; import org.junit.Test; -import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridRowElement; -import com.vaadin.testbench.parallel.Browser; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @TestCategory("grid") public class GridSubPixelProblemWrappingTest extends MultiBrowserTest { - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - List<DesiredCapabilities> l = super.getBrowsersToTest(); - // Currently broken because of #18214 - l.remove(Browser.IE9.getDesiredCapabilities()); - return l; - } - @Test public void addedRowShouldNotWrap() { openTestURL(); diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java index a341e39b74..d1d7b21e11 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java @@ -195,4 +195,17 @@ public class GridClientSelectionTest extends GridBasicClientFeaturesTest { isRowSelected(1)); } + @Test + public void testChangeSelectionModelUpdatesUI() { + openTestURL(); + + setSelectionModelSingle(true); + getGridElement().getCell(5, 1).click(); + assertTrue("Row 5 should be selected after clicking", isRowSelected(5)); + setSelectionModelNone(); + assertFalse( + "Row 5 should not be selected after changing selection model", + isRowSelected(5)); + + } } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java index b4eb473d4b..9953bbcae0 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java @@ -271,6 +271,20 @@ public class GridSelectionTest extends GridBasicFeaturesTest { } @Test + public void testSelectAllCheckboxWithHeaderOperations() { + openTestURL(); + + setSelectionModelMulti(); + selectMenuPath("Component", "Header", "Prepend row"); + selectMenuPath("Component", "Header", "Append row"); + + GridCellElement header = getGridElement().getHeaderCell(1, 0); + assertTrue("Multi Selection Model should have select all checkbox", + header.isElementPresent(By.tagName("input"))); + + } + + @Test public void testToggleDeselectAllowed() { openTestURL(); @@ -305,6 +319,22 @@ public class GridSelectionTest extends GridBasicFeaturesTest { .isSelected()); } + @Test + public void testChangeSelectionModelUpdatesUI() { + openTestURL(); + + setSelectionModelSingle(); + + getGridElement().getCell(5, 1).click(); + assertTrue("Row should be selected after clicking", getRow(5) + .isSelected()); + + setSelectionModelNone(); + assertFalse( + "Row should not be selected after changing selection model", + getRow(5).isSelected()); + } + private void setSelectionModelMulti() { selectMenuPath("Component", "State", "Selection mode", "multi"); } diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChild.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChild.java new file mode 100644 index 0000000000..034ff024d0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChild.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; + +public class GridLayoutFocusOrderAfterShowChild extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + GridLayout gl = new GridLayout(2, 5); + gl.setId("grid"); + gl.setMargin(true); + gl.setSpacing(true); + + final Label l1 = new Label("First"); + l1.setWidthUndefined(); + l1.setVisible(false); + gl.addComponent(l1); + + final TextField t1 = new TextField(); + t1.setId("t1"); + t1.setVisible(false); + t1.setWidthUndefined(); + gl.addComponent(t1); + + Label l2 = new Label("Second"); + l2.setWidthUndefined(); + gl.addComponent(l2); + + TextField t2 = new TextField(); + t2.setId("t2"); + gl.addComponent(t2); + + final Label l3 = new Label("Third"); + l3.setWidthUndefined(); + l3.setVisible(false); + gl.addComponent(l3); + + final TextField t3 = new TextField(); + t3.setId("t3"); + t3.setVisible(false); + gl.addComponent(t3); + + Label l4 = new Label("Fourth"); + l4.setWidthUndefined(); + gl.addComponent(l4); + + TextField t4 = new TextField(); + t4.setId("t4"); + gl.addComponent(t4); + + final Label l5 = new Label("Fifth"); + l5.setWidthUndefined(); + l5.setVisible(false); + gl.addComponent(l5); + + final TextField t5 = new TextField(); + t5.setId("t5"); + t5.setVisible(false); + gl.addComponent(t5); + + addComponent(gl); + + addComponent(new Button("Show first", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + t1.setVisible(true); + l1.setVisible(true); + } + })); + + addComponent(new Button("Show third", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + t3.setVisible(true); + l3.setVisible(true); + } + })); + + addComponent(new Button("Show fifth", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + t5.setVisible(true); + l5.setVisible(true); + } + })); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java new file mode 100644 index 0000000000..1913fbfdf9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridLayoutElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutFocusOrderAfterShowChildTest extends MultiBrowserTest { + + @Test + public void showComponentBreaksFocusOrderFirst() + throws IOException, Exception { + openTestURL(); + + GridLayoutElement grid = $(GridLayoutElement.class).id("grid"); + + $(ButtonElement.class).first().click(); + + Assert.assertEquals("First", + grid.$(LabelElement.class).first().getText()); + grid.$(TextFieldElement.class).first().focus(); + + grid.$(TextFieldElement.class).first().sendKeys(Keys.TAB); + + Assert.assertEquals("t2", + driver.switchTo().activeElement().getAttribute("id")); + } + + @Test + public void showComponentBreaksFocusOrderMiddle() + throws IOException, Exception { + openTestURL(); + + GridLayoutElement grid = $(GridLayoutElement.class).id("grid"); + + $(ButtonElement.class).get(1).click(); + + Assert.assertEquals("Third", + grid.$(LabelElement.class).get(1).getText()); + grid.$(TextFieldElement.class).first().focus(); + + grid.$(TextFieldElement.class).first().sendKeys(Keys.TAB); + + Assert.assertEquals("t3", + driver.switchTo().activeElement().getAttribute("id")); + } + + @Test + public void showComponentBreaksFocusOrderLast() + throws IOException, Exception { + openTestURL(); + + GridLayoutElement grid = $(GridLayoutElement.class).id("grid"); + + $(ButtonElement.class).get(2).click(); + + Assert.assertEquals("Fifth", + grid.$(LabelElement.class).get(2).getText()); + grid.$(TextFieldElement.class).get(1).focus(); + + grid.$(TextFieldElement.class).get(1).sendKeys(Keys.TAB); + + Assert.assertEquals("t5", + driver.switchTo().activeElement().getAttribute("id")); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java b/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java index e6b3ca2af4..e5e5163442 100644 --- a/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java +++ b/uitest/src/com/vaadin/tests/components/table/ContextMenuSizeTest.java @@ -27,7 +27,6 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; -import com.vaadin.testbench.parallel.Browser; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -39,10 +38,7 @@ public class ContextMenuSizeTest extends MultiBrowserTest { @Override public List<DesiredCapabilities> getBrowsersToTest() { - // context menu doesn't work in phantom JS and works weirdly with IE8 - // and selenium. - return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11, - Browser.FIREFOX, Browser.CHROME); + return getBrowsersSupportingContextMenu(); } @Override diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java new file mode 100644 index 0000000000..81d906bec3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeContextMenuAndIconsTest.java @@ -0,0 +1,130 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tree; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TreeContextMenuAndIconsTest extends MultiBrowserTest { + + @Override + protected Class<?> getUIClass() { + return Trees.class; + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return getBrowsersSupportingContextMenu(); + } + + @Test + public void testSimpleContextMenu() throws Exception { + openTestURL(); + + selectMenuPath("Settings", "Show event log"); + selectMenuPath("Component", "Features", "Context menu", + "Item without icon"); + + openContextMenu(getTreeNodeByCaption("Item 1")); + + compareScreen("contextmenu-noicon"); + + closeContextMenu(); + } + + @Test + public void testContextMenuWithAndWithoutIcon() throws Exception { + openTestURL(); + + selectMenuPath("Settings", "Show event log"); + selectMenuPath("Component", "Features", "Context menu", + "With and without icon"); + + openContextMenu(getTreeNodeByCaption("Item 1")); + + compareScreen("caption-only-and-has-icon"); + + closeContextMenu(); + } + + @Test + public void testContextLargeIcon() throws Exception { + openTestURL(); + + selectMenuPath("Settings", "Show event log"); + selectMenuPath("Component", "Features", "Context menu", + "Only one large icon"); + + WebElement menu = openContextMenu(getTreeNodeByCaption("Item 1")); + + // reindeer doesn't support menu with larger row height, so the + // background image contains parts of other sprites => + // just check that the menu is of correct size + Dimension size = menu.getSize(); + Assert.assertEquals("Menu height with large icons", 74, size.height); + + closeContextMenu(); + } + + @Test + public void testContextRemoveIcon() throws Exception { + openTestURL(); + + selectMenuPath("Settings", "Show event log"); + selectMenuPath("Component", "Features", "Context menu", + "Only one large icon"); + + openContextMenu(getTreeNodeByCaption("Item 1")); + closeContextMenu(); + + selectMenuPath("Component", "Features", "Context menu", + "Item without icon"); + + openContextMenu(getTreeNodeByCaption("Item 1")); + + compareScreen("contextmenu-noicon"); + + closeContextMenu(); + } + + private WebElement openContextMenu(WebElement element) { + Actions actions = new Actions(getDriver()); + // Note: on Firefox, the first menu item does not get focus; on other + // browsers it does + actions.contextClick(element); + actions.perform(); + return findElement(By.className("v-contextmenu")); + } + + private void closeContextMenu() { + findElement(By.className("v-app")).click(); + } + + private WebElement getTreeNodeByCaption(String caption) { + return getDriver().findElement( + By.xpath("//span[text() = '" + caption + "']")); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/upload/DragAndDropUploadAndInteractions.java b/uitest/src/com/vaadin/tests/components/upload/DragAndDropUploadAndInteractions.java new file mode 100644 index 0000000000..952fe08b79 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/DragAndDropUploadAndInteractions.java @@ -0,0 +1,153 @@ +package com.vaadin.tests.components.upload; + +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.apache.commons.io.output.ByteArrayOutputStream; + +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.StreamVariable; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.Html5File; +import com.vaadin.ui.Panel; + +public class DragAndDropUploadAndInteractions extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + ComboBox comboBox = new ComboBox(); + for (int i = 0; i < 10; i++) { + comboBox.addItem("Test " + i); + } + addComponent(comboBox); + Button b = new Button("Dummy"); + addComponent(b); + Panel p = new Panel(); + p.setHeight(200, Unit.PIXELS); + p.setWidth(200, Unit.PIXELS); + MyUploadPanel myUploadPanel = new MyUploadPanel(p); + addComponent(myUploadPanel); + } + + class MyUploadPanel extends DragAndDropWrapper implements DropHandler { + private static final long serialVersionUID = 1L; + + public MyUploadPanel(Component root) { + super(root); + setDropHandler(this); + } + + @Override + public void drop(DragAndDropEvent event) { + WrapperTransferable tr = (WrapperTransferable) event + .getTransferable(); + Html5File[] files = tr.getFiles(); + + if (files != null) { + List<Html5File> filesToUpload = Arrays.asList(files); + for (Html5File file : filesToUpload) { + file.setStreamVariable(new MyStreamVariable()); + } + } + } + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + } + + class MyStreamVariable implements StreamVariable { + private static final long serialVersionUID = 1L; + + @Override + public OutputStream getOutputStream() { + return new ByteArrayOutputStream(); + } + + @Override + public boolean listenProgress() { + return true; + } + + long lastEvent = 0; + long lastTime = 0; + + @Override + public void onProgress(StreamingProgressEvent event) { + long received = event.getBytesReceived() - lastEvent; + long now = new Date().getTime(); + long time = now - lastTime; + lastTime = now; + lastEvent = event.getBytesReceived(); + if (time == 0) { + return; + } + log("Received " + received + " bytes in " + time + "ms: " + + formatSize(received / (time / 1000.0)) + "/s"); + log("Streaming OnProgress - ContentLength: " + + formatSize(event.getContentLength()) + + " - Bytes Received: " + + formatSize(event.getBytesReceived())); + } + + @Override + public void streamingStarted(StreamingStartEvent event) { + lastEvent = 0; + lastTime = new Date().getTime(); + log("Streaming Started - ContentLength: " + + formatSize(event.getContentLength()) + + " - Bytes Received: " + + formatSize(event.getBytesReceived())); + } + + @Override + public void streamingFinished(StreamingEndEvent event) { + log("Streaming Finished - ContentLength: " + + formatSize(event.getContentLength()) + + " - Bytes Received: " + + formatSize(event.getBytesReceived())); + } + + @Override + public void streamingFailed(StreamingErrorEvent event) { + log("Streaming Failed - ContentLength: " + + formatSize(event.getContentLength()) + + " - Bytes Received: " + + formatSize(event.getBytesReceived())); + } + + @Override + public boolean isInterrupted() { + return false; + } + + } + + protected String formatSize(double contentLength) { + double d = contentLength; + int suffix = 0; + String[] suffixes = new String[] { "B", "KB", "MB", "GB", "TB" }; + while (d > 1024) { + suffix++; + d /= 1024.0; + } + return String.format("%.1f %s", d, suffixes[suffix]); + } + + @Override + protected String getTestDescription() { + return "Drop a large (100 MB) file using IE10 and interact with the application while uploading. Ensure the uploads succeeds even though you are interacting with the app."; + } +} diff --git a/uitest/src/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContentTest.java b/uitest/src/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContentTest.java new file mode 100644 index 0000000000..057a43f495 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContentTest.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.components.window; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; + +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.newelements.WindowElement; + +public class UndefinedHeightSubWindowAndContentTest extends MultiBrowserTest { + + @Test + public void testUndefinedHeight() { + openTestURL(); + + TextFieldElement textField = $(TextFieldElement.class).first(); + + textField.click(); + textField.sendKeys("invalid", Keys.ENTER); + + WindowElement window = $(WindowElement.class).first(); + int height = window.getSize().getHeight(); + Assert.assertTrue("Window height with validation failure", + 161 <= height && height <= 164); + + textField.setValue("valid"); + textField.sendKeys(Keys.ENTER); + height = window.getSize().getHeight(); + Assert.assertTrue("Window height with validation success", + 136 <= height && height <= 139); + } + +} diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java new file mode 100644 index 0000000000..9f9453d505 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStyles.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.extensions; + +import com.vaadin.annotations.StyleSheet; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +@StyleSheet("http://fonts.googleapis.com/css?family=Cabin+Sketch") +public class ResponsiveWithCrossDomainStyles extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + addComponent(new Button("Make responsive", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + event.getButton().setResponsive(true); + } + })); + } + +} diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStylesTest.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStylesTest.java new file mode 100644 index 0000000000..4089618635 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveWithCrossDomainStylesTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.extensions; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ResponsiveWithCrossDomainStylesTest extends MultiBrowserTest { + @Test + public void testResponsive() { + setDebug(true); + openTestURL(); + + $(ButtonElement.class).first().click(); + + assertNoErrorNotifications(); + } + +} diff --git a/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java b/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java index a223cea6a0..52d3e60af5 100644 --- a/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java +++ b/uitest/src/com/vaadin/tests/fieldgroup/BasicPersonForm.java @@ -131,7 +131,9 @@ public class BasicPersonForm extends AbstractTestUIWithLog { } catch (CommitException e) { msg = "Commit failed: " + e.getMessage(); } - Notification.show(msg); + Notification notification = new Notification(msg); + notification.setDelayMsec(Notification.DELAY_FOREVER); + notification.show(getPage()); log(msg); } diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index edcd07ee89..842fcbb859 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -240,6 +240,15 @@ public abstract class AbstractTB3Test extends ParallelTest { * debug window and/or push (depending on {@link #isDebug()} and * {@link #isPush()}. */ + protected void openTestURL() { + openTestURL(new String[0]); + } + + /** + * Opens the given test (defined by {@link #getTestUrl()}, optionally with + * debug window and/or push (depending on {@link #isDebug()} and + * {@link #isPush()}. + */ protected void openTestURL(String... parameters) { openTestURL(getUIClass(), parameters); } diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index 678b38c4f1..a678009d85 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -80,6 +80,13 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration { Browser.IE11); } + protected List<DesiredCapabilities> getBrowsersSupportingContextMenu() { + // context menu doesn't work in phantom JS and works weirdly with IE8 + // and selenium. + return getBrowserCapabilities(Browser.IE9, Browser.IE10, Browser.IE11, + Browser.FIREFOX, Browser.CHROME); + } + @Override public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) { if (BrowserUtil.isIE(desiredCapabilities)) { |