diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-15 10:24:44 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-15 10:24:44 +0300 |
commit | 2c4e533c9f2aa68211329ea6ce4de0b577407863 (patch) | |
tree | 1d9c1cc8bb72678b0edb991947c6fc94112baf0f /uitest | |
parent | 93235f05c9dd4739cdccf87a4858a61904dbf4b5 (diff) | |
parent | 7cb23bc63f794a7549dd79c37da2f8bb8e88e20d (diff) | |
download | vaadin-framework-2c4e533c9f2aa68211329ea6ce4de0b577407863.tar.gz vaadin-framework-2c4e533c9f2aa68211329ea6ce4de0b577407863.zip |
Merge remote-tracking branch 'origin/master' into grid-7.5
Change-Id: I03fdd2014fd0393341db0f650c065f6d27905b73
Diffstat (limited to 'uitest')
17 files changed, 1126 insertions, 4 deletions
diff --git a/uitest/eclipse-run-selected-test.properties b/uitest/eclipse-run-selected-test.properties index f8fb0a8c14..535885f877 100644 --- a/uitest/eclipse-run-selected-test.properties +++ b/uitest/eclipse-run-selected-test.properties @@ -22,8 +22,13 @@ com.vaadin.testbench.screenshot.directory=<enter the full path to the screenshot ; ; Simulates @RunLocally with the given value on all test classes without a @RunLocally annotation. +; Use simple browser name (phantomjs, chrome, firefox, ie8, ie9, ie10, ie11) ; com.vaadin.testbench.runLocally=firefox +; By default using @RunLocally annotation in Framework tests is not allowed. +; Running tests locally can be done with com.vaadin.testbench.runLocally parameter above. +; Uncomment the following line if you want to be able to use @RunLocally annotation +; com.vaadin.testbench.allowRunLocally=true ; ; For only TestBench 2 diff --git a/uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java b/uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java new file mode 100644 index 0000000000..ac4b48711e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java @@ -0,0 +1,66 @@ +package com.vaadin.tests.components; + +import com.vaadin.annotations.Viewport; +import com.vaadin.data.util.converter.StringToIntegerConverter; +import com.vaadin.data.validator.IntegerRangeValidator; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +@Viewport(value = "width=device-width,height=device-height") +public class TouchDevicesTooltip extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Label errorLabel = new Label("No error"); + addComponent(errorLabel); + + for (int i = 0; i < 50; i++) { + createTextField(i); + } + } + + private void createTextField(int n) { + TextField textField = new TextField("Value" + n); + textField.setConverter(new StringToIntegerConverter()); + textField.addValidator(new IntegerRangeValidator(getErrorMessage(n), 0, 100)); + textField.setImmediate(true); + textField.setValue("-5"); + addComponent(textField); + } + + private String getErrorMessage(int n) { + if(n % 2 == 0) { + return "incorrect value" + n; + } else { + return "super long long long long long long long long long long long error message " + n; + } + } + + public static class Bean { + @NotNull + @Min(0) + private Integer value; + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } + } + + @Override + protected Integer getTicketNumber() { + return 17150; + } + + @Override + public String getDescription() { + return "Unable to dismiss a tooltip on touch devices"; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/colorpicker/DefaultCaptionWidth.java b/uitest/src/com/vaadin/tests/components/colorpicker/DefaultCaptionWidth.java new file mode 100644 index 0000000000..d3dd0aeccc --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/colorpicker/DefaultCaptionWidth.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.colorpicker; + +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.ColorPicker; + +/** + * Test for color picker with default caption. + * + * @author Vaadin Ltd + */ +public class DefaultCaptionWidth extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final ColorPicker colorPicker = new ColorPicker(); + addComponent(colorPicker); + colorPicker.setDefaultCaptionEnabled(true); + + Button setWidth = new Button("Set explicit width", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + colorPicker.setCaption(null); + colorPicker.setWidth("150px"); + } + }); + setWidth.addStyleName("set-width"); + addComponent(setWidth); + + Button setCaption = new Button("Set explicit caption", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + colorPicker.setCaption("caption"); + colorPicker.setWidthUndefined(); + } + }); + setCaption.addStyleName("set-caption"); + addComponent(setCaption); + + } + + @Override + protected String getTestDescription() { + return "Color picker with default caption enabled should get appropriate style"; + } + + @Override + protected Integer getTicketNumber() { + return 17140; + } +} diff --git a/uitest/src/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java b/uitest/src/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java new file mode 100644 index 0000000000..78b7120b4e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java @@ -0,0 +1,67 @@ +/* + * 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.colorpicker; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.ColorPickerElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for default caption behavior in color picker. + * + * @author Vaadin Ltd + */ +public class DefaultCaptionWidthTest extends MultiBrowserTest { + + @Before + public void setUp() { + openTestURL(); + } + + @Test + public void setDefaultCaption_sizeAndCaptionAreNotSet_pickerGetsStyle() { + checkStylePresence(true); + } + + @Test + public void setDefaultCaption_explicitSizeIsSet_pickerNoCaptionStyle() { + findElement(By.className("set-width")).click(); + checkStylePresence(false); + } + + @Test + public void setDefaultCaption_explicitCaptionIsSet_pickerNoCaptionStyle() { + findElement(By.className("set-caption")).click(); + checkStylePresence(false); + } + + protected void checkStylePresence(boolean expectedStyle) { + String clazz = $(ColorPickerElement.class).first() + .getAttribute("class"); + if (expectedStyle) { + Assert.assertTrue("Default caption style is not found", + clazz.contains("v-default-caption-width")); + } else { + Assert.assertFalse("Found unexpected default caption style", + clazz.contains("v-default-caption-width")); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxMouseSelectEnter.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxMouseSelectEnter.java new file mode 100644 index 0000000000..5af4749349 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxMouseSelectEnter.java @@ -0,0 +1,66 @@ +/* + * 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.combobox; + +import com.vaadin.data.Property; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; + +public class ComboBoxMouseSelectEnter extends AbstractTestUI { + protected ComboBox comboBox; + + @Override + protected void setup(VaadinRequest request) { + comboBox = new ComboBox(); + final Label label = new Label(); + label.setId("value"); + + comboBox.setTextInputAllowed(true); + comboBox.setNullSelectionAllowed(true); + comboBox.setNullSelectionItemId(null); + + for (int i = 0; i < 10; i++) { + comboBox.addItem("a" + i); + } + + comboBox.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(Property.ValueChangeEvent event) { + Object value = event.getProperty().getValue(); + if (value != null) { + label.setValue(value.toString()); + } else { + label.setValue("null"); + } + } + }); + + addComponents(comboBox); + addComponent(label); + } + + @Override + protected String getTestDescription() { + return "Pressing Enter should set value highlighted from mouse position after using arrow keys"; + } + + @Override + protected Integer getTicketNumber() { + return 16981; + } +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxMouseSelectEnterTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxMouseSelectEnterTest.java new file mode 100644 index 0000000000..d3ba37682d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxMouseSelectEnterTest.java @@ -0,0 +1,105 @@ +/* + * 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.combobox; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.parallel.BrowserUtil; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.newelements.ComboBoxElement; + +public class ComboBoxMouseSelectEnterTest extends MultiBrowserTest { + + private ComboBoxElement comboBoxElement; + + @Override + public void setup() throws Exception { + + super.setup(); + openTestURL(); + waitForElementPresent(By.className("v-filterselect")); + comboBoxElement = $(ComboBoxElement.class).first(); + } + + @Test + public void enterSetsValueSelectedByMouseOver() { + comboBoxElement.openPopup(); + comboBoxElement.sendKeys(Keys.DOWN, Keys.DOWN); + String selectedItemText = findElement( + By.className("gwt-MenuItem-selected")).getText(); + assertThat("Item selected by arrows should be a1", selectedItemText, + is("a1")); + new Actions(driver).moveToElement(getWebElementForItem("a5")).build() + .perform(); + comboBoxElement.sendKeys(getReturn()); + assertThat("Item selected by mouse should be a5", + comboBoxElement.getText(), is("a5")); + checkLabelValue("a5"); + } + + private WebElement getWebElementForItem(String wantedText) { + WebElement wantedItem = null; + List<WebElement> items = findElements(By.className("gwt-MenuItem")); + for (WebElement item : items) { + if (item.getText().equals(wantedText)) { + wantedItem = item; + break; + } + } + return wantedItem; + } + + private Keys getReturn() { + if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { + return Keys.ENTER; + } else { + return Keys.RETURN; + } + } + + private void checkLabelValue(final String expectedValue) { + + waitUntil(new ExpectedCondition<Boolean>() { + private String actualValue; + + @Override + public Boolean apply(WebDriver input) { + actualValue = $(LabelElement.class).id("value").getText(); + return actualValue.equals(expectedValue); + } + + @Override + public String toString() { + // Timed out after 10 seconds waiting for ... + return String.format("Label value to match '%s' (was: '%s')", + expectedValue, actualValue); + } + }); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/grid/GridHeaderFormatChange.java b/uitest/src/com/vaadin/tests/components/grid/GridHeaderFormatChange.java new file mode 100644 index 0000000000..fbd6a42a38 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridHeaderFormatChange.java @@ -0,0 +1,183 @@ +/* + * 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.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.HeaderRow; +import com.vaadin.ui.Grid.SelectionMode; +import com.vaadin.ui.Grid.SelectionModel; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.renderers.NumberRenderer; + +public class GridHeaderFormatChange extends AbstractTestUI { + + private static final long serialVersionUID = -2787771187365766027L; + + private HeaderRow row; + + public class Person implements Serializable { + private static final long serialVersionUID = -7995927620756317000L; + + String firstName; + String lastName; + String streetAddress; + Integer zipCode; + String city; + + public Person(String firstName, String lastName, String streetAddress, + Integer zipCode, String city) { + this.firstName = firstName; + this.lastName = lastName; + this.streetAddress = streetAddress; + this.zipCode = zipCode; + this.city = city; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getStreetAddress() { + return streetAddress; + } + + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + public Integer getZipCode() { + return zipCode; + } + + public void setZipCode(Integer zipCode) { + this.zipCode = zipCode; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + } + + @Override + protected void setup(VaadinRequest request) { + BeanItemContainer<Person> datasource = new BeanItemContainer<Person>( + Person.class); + final Grid grid; + + datasource.addItem(new Person("Rudolph", "Reindeer", "Ruukinkatu 2-4", + 20540, "Turku")); + + grid = new Grid(datasource); + grid.setWidth("600px"); + grid.getColumn("zipCode").setRenderer(new NumberRenderer()); + grid.setColumnOrder("firstName", "lastName", "streetAddress", + "zipCode", "city"); + grid.setSelectionMode(SelectionMode.SINGLE); + addComponent(grid); + + Button showHide = new Button("Hide firstName", + new Button.ClickListener() { + private static final long serialVersionUID = 8107530972693788705L; + + @Override + public void buttonClick(ClickEvent event) { + if (grid.getColumn("firstName") != null) { + grid.removeColumn("firstName"); + event.getButton().setCaption("Show firstName"); + } else { + grid.addColumn("firstName"); + grid.setColumnOrder("firstName", "lastName", + "streetAddress", "zipCode", "city"); + + event.getButton().setCaption("Hide firstName"); + } + } + }); + showHide.setId("show_hide"); + + Button selectionMode = new Button("Set multiselect", + new Button.ClickListener() { + private static final long serialVersionUID = 8107530972693788705L; + + @Override + public void buttonClick(ClickEvent event) { + if (grid.getSelectionModel() instanceof SelectionModel.Single) { + grid.setSelectionMode(SelectionMode.MULTI); + } else { + grid.setSelectionMode(SelectionMode.SINGLE); + } + } + }); + selectionMode.setId("selection_mode"); + + Button join = new Button("Add Join header column", + new Button.ClickListener() { + private static final long serialVersionUID = -5330801275551280623L; + + @Override + public void buttonClick(ClickEvent event) { + if (row == null) { + row = grid.prependHeaderRow(); + if (grid.getColumn("firstName") != null) { + row.join("firstName", "lastName").setText( + "Full Name"); + } + row.join("streetAddress", "zipCode", "city") + .setText("Address"); + } else { + grid.removeHeaderRow(row); + row = null; + } + } + }); + join.setId("join"); + addComponent(new HorizontalLayout(showHide, selectionMode, join)); + } + + @Override + protected String getTestDescription() { + return "Grid for testing header re-rendering."; + } + + @Override + protected Integer getTicketNumber() { + return 17131; + } +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java b/uitest/src/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java new file mode 100644 index 0000000000..0e2a3d6ac6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java @@ -0,0 +1,156 @@ +/* + * 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.ButtonElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +@TestCategory("grid") +public class GridHeaderFormatChangeTest extends MultiBrowserTest { + + @Test + public void testHeaderRetainsSelectAllForColumnRemoval() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + + // Assert that we do not have the select all checkbox + Assert.assertTrue( + "Found input in header even though none should exist.", grid + .getHeader().findElements(By.tagName("input")) + .isEmpty()); + + // Set grid into multiselection mode + toggleSelectionMode(); + + // Assert that we now have a select all checkbox in the header + Assert.assertFalse("Expected one input field in header", grid + .getHeader().findElements(By.tagName("input")).isEmpty()); + + // Hide the firstName column from the grid. + toggleFirstName(); + + // Assert that we still have the select all checkbox in the header. + Assert.assertFalse("Header was missing checkbox after hiding column", + grid.getHeader().findElements(By.tagName("input")).isEmpty()); + + // Show the firstName column. + toggleFirstName(); + + // Assert that we still have the select all checkbox in the header. + Assert.assertFalse( + "Header was missing checkbox after bringing back column", grid + .getHeader().findElements(By.tagName("input")) + .isEmpty()); + } + + @Test + public void testHeaderRetainsSelectAllForJoinColumnAdd() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + + // Assert that we do not have the select all checkbox + Assert.assertTrue( + "Found input in header even though none should exist.", grid + .getHeader().findElements(By.tagName("input")) + .isEmpty()); + + // Set grid into multiselection mode + toggleSelectionMode(); + + // Assert that we now have a select all checkbox in the header + Assert.assertFalse("Expected one input field in header", grid + .getHeader().findElements(By.tagName("input")).isEmpty()); + + // Add Join columns header + toggleJoin(); + + // Assert that we still have the select all checkbox in the header. + Assert.assertFalse("Header was missing checkbox after hiding column", + grid.getHeader().findElements(By.tagName("input")).isEmpty()); + + // remove Join Columns header + toggleJoin(); + + // Assert that we still have the select all checkbox in the header. + Assert.assertFalse( + "Header was missing checkbox after bringing back column", grid + .getHeader().findElements(By.tagName("input")) + .isEmpty()); + } + + @Test + public void selectAllShouldKeepState() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + + // Assert that we do not have the select all checkbox + Assert.assertTrue( + "Found input in header even though none should exist.", grid + .getHeader().findElements(By.tagName("input")) + .isEmpty()); + + // Set grid into multiselection mode + toggleSelectionMode(); + + // Assert that we now have a select all checkbox in the header + Assert.assertFalse("Should not be selected after adding", grid + .getHeader().findElement(By.tagName("input")).isSelected()); + + grid.getHeader().findElement(By.tagName("input")).click(); + + // Assert that checkbox is checked + assertSelectAllChecked( + "Not selected even though we just clicked selection", grid); + + // Hide the firstName column from the grid. + toggleFirstName(); + + // Assert that checkbox is still checked + assertSelectAllChecked("Selection disappeared after removing column", + grid); + + // Show the firstName column. + toggleFirstName(); + + // Assert that checkbox is still checked + assertSelectAllChecked("Selection disappeared after adding column", + grid); + + } + + private void assertSelectAllChecked(String message, GridElement grid) { + Assert.assertTrue(message, + grid.getHeader().findElement(By.tagName("input")).isSelected()); + } + + private void toggleSelectionMode() { + $(ButtonElement.class).id("selection_mode").click(); + } + + private void toggleFirstName() { + $(ButtonElement.class).id("show_hide").click(); + } + + private void toggleJoin() { + $(ButtonElement.class).id("join").click(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUI.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUI.java new file mode 100644 index 0000000000..d2ca7700ad --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUI.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.datefield.Resolution; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.Label; + +@SuppressWarnings("serial") +public class GridLayoutCellSizesUI extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + + // Create a 4 by 4 grid layout + final GridLayout grid = new GridLayout(4, 4); + + // Fill out the first row using the cursor + grid.addComponent(new Button("R/C 1")); + for (int i = 0; i < 3; i++) { + grid.addComponent(new Button("Col " + (grid.getCursorX() + 1))); + } + + // Fill out the first column using coordinates + for (int i = 1; i < 4; i++) { + grid.addComponent(new Button("Row " + i), 0, i); + } + + // Add some components of various shapes. + grid.addComponent(new Button("3x1 button"), 1, 1, 3, 1); + grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3); + final InlineDateField date = new InlineDateField("A 2x2 date field"); + date.setResolution(Resolution.DAY); + grid.addComponent(date, 2, 2, 3, 3); + + grid.setMargin(true); + grid.setSizeUndefined(); + + addComponent(grid); + } + + @Override + protected Integer getTicketNumber() { + return 17039; + } + + @Override + protected String getTestDescription() { + return "Grid cells should be full size when adding borders around the cells"; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java new file mode 100644 index 0000000000..8c753b1f5c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java @@ -0,0 +1,111 @@ +/* + * 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.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.GridLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutCellSizesUITest extends MultiBrowserTest { + + private List<WebElement> slots4x4; + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + slots4x4 = getSlots(); + } + + @Test + public void equalsHeightSlotsShouldHaveTheSameHeight() { + // items in positions 0,1,2,3,4,5 should have the same height + int firstSlotHeight = getSlotHeight(0); + for (int i = 1; i < 6; i++) { + Assert.assertEquals("Cell height didn't match for cell: " + i, + firstSlotHeight, getSlotHeight(i)); + } + } + + @Test + public void expandedAndLargeSizeSlotsShouldNotEqualFirstSlot() { + int firstSlotHeight = getSlotHeight(0); + + assertNotMatchesSmallHeight(firstSlotHeight, 6, "Row 2"); + assertNotMatchesSmallHeight(firstSlotHeight, 7, "1x2 cell"); + assertNotMatchesSmallHeight(firstSlotHeight, 8, "A 2x2 date field"); + assertNotMatchesSmallHeight(firstSlotHeight, 9, "Row 3"); + } + + @Test + public void expandedRowsShouldHaveCorrectHeight() { + // Slots expanding over 2 rows should have the same height. + Assert.assertEquals("1x2 and 2x2 cell heights didn't match", + getSlotHeight(7), getSlotHeight(8)); + + // Slots on same row as the 1x2 label should have the same combined + // height. + Assert.assertEquals( + "1x2 and combined row two and row three cell heights didn't match", + getSlotHeight(7), getSlotHeight(6) + getSlotHeight(9)); + } + + @Test + public void expandedRowsShouldHaveCorrectWidth() { + // Col 2 slot should be the dame width as 1x2 cell slot + Assert.assertEquals( + "Col 2 slot was not the same width as slot for 1x2 cell", + getSlotWidth(1), getSlotWidth(7)); + + // Row one col 3 & 4 should be as wide as the 2x2 date field + Assert.assertEquals( + "2x2 date field width didn't match col 3 & col 4 combined width", + getSlotWidth(8), getSlotWidth(2) + getSlotWidth(3)); + + // 3x1 button should be as wide as 1x2cell + 2x2 data field + Assert.assertEquals( + "3x1 slot width wasn't the same as the combined slot widths of 1x2 cell and 2x2 date field", + getSlotWidth(5), getSlotWidth(7) + getSlotWidth(8)); + + } + + private void assertNotMatchesSmallHeight(int firstSlotHeight, int i, + String id) { + Assert.assertNotEquals("Big slot '" + id + + "' matched small slots in height", firstSlotHeight, + getSlotHeight(i)); + } + + private int getSlotHeight(int slot) { + return slots4x4.get(slot).getSize().height; + } + + private int getSlotWidth(int slot) { + return slots4x4.get(slot).getSize().width; + } + + private List<WebElement> getSlots() { + GridLayoutElement layout = $(GridLayoutElement.class).first(); + + return layout.findElements(By.className("v-gridlayout-slot")); + } +} diff --git a/uitest/src/com/vaadin/tests/components/notification/ChromeBottomNotification.java b/uitest/src/com/vaadin/tests/components/notification/ChromeBottomNotification.java new file mode 100644 index 0000000000..0fdc8df360 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/notification/ChromeBottomNotification.java @@ -0,0 +1,33 @@ +package com.vaadin.tests.components.notification; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.Position; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Notification; + +public class ChromeBottomNotification extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + addButton("Show notification", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + Notification notification = new Notification( + "Hello world", + Notification.Type.ERROR_MESSAGE); + notification.setPosition(Position.BOTTOM_CENTER); + notification.show(getPage()); + } + }); + } + + @Override + protected Integer getTicketNumber() { + return 17252; + } + + @Override + public String getDescription() { + return "Bottom notification on Chrome goes up to top"; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java b/uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java new file mode 100644 index 0000000000..1d909d101e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java @@ -0,0 +1,106 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.Action; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +/* + * Differs from TableContextMenu by number of items, their numbering and + * immediate/selectable/multiselect toggling + */ +public class TableContextMenuTouch extends AbstractTestUI { + + private static final Action ACTION_MYACTION = new Action("Action!!"); + + @Override + protected void setup(VaadinRequest req) { + + HorizontalLayout hlay = new HorizontalLayout(); + addComponent(hlay); + hlay.setSpacing(true); + + final Table table = new Table(); + + table.addActionHandler(new Action.Handler() { + @Override + public void handleAction(Action action, Object sender, Object target) { + Notification.show("Done that :-)"); + } + + @Override + public Action[] getActions(Object target, Object sender) { + return new Action[] { ACTION_MYACTION }; + } + }); + + table.addContainerProperty("Foo", String.class, "BAR1"); + table.addContainerProperty("Bar", String.class, "FOO2"); + + table.setHeight("200px"); + + for (int i = 0; i < 30; i++) { + Object key = table.addItem(); + table.getItem(key).getItemProperty("Foo") + .setValue(new Integer(i).toString()); + } + + hlay.addComponent(table); + + VerticalLayout vlay = new VerticalLayout(); + hlay.addComponent(vlay); + + final CheckBox immediateCheckBox = new CheckBox("Immediate"); + vlay.addComponent(immediateCheckBox); + immediateCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setImmediate(immediateCheckBox.getValue()); + } + }); + immediateCheckBox.setValue(true); + table.setImmediate(immediateCheckBox.getValue()); + + final CheckBox selectableCheckBox = new CheckBox("Selectable"); + final CheckBox multiselectCheckBox = new CheckBox("Multiselect"); + vlay.addComponent(selectableCheckBox); + selectableCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setSelectable(selectableCheckBox.getValue()); + multiselectCheckBox.setEnabled(selectableCheckBox.getValue()); + } + }); + selectableCheckBox.setValue(true); + multiselectCheckBox.setEnabled(selectableCheckBox.getValue()); + table.setSelectable(selectableCheckBox.getValue()); + + vlay.addComponent(multiselectCheckBox); + multiselectCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setMultiSelect(multiselectCheckBox.getValue()); + } + }); + multiselectCheckBox.setValue(true); + table.setMultiSelect(multiselectCheckBox.getValue()); + + } + + @Override + protected String getTestDescription() { + return "Context menu in Table on touch devices should not open on selection tapping"; + } + + @Override + protected Integer getTicketNumber() { + return 15297; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index a95def5983..2d032ecd9e 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -142,7 +142,6 @@ public abstract class AbstractTB3Test extends ParallelTest { } catch (UnsupportedOperationException e) { // Opera does not support this... } - } /** @@ -244,7 +243,7 @@ public abstract class AbstractTB3Test extends ParallelTest { private void openTestURL(Class<?> uiClass, Set<String> parameters) { String url = getTestURL(uiClass); - if(isDebug()) { + if (isDebug()) { parameters.add("debug"); } diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index d0134a4feb..dce725b7c0 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -25,9 +25,11 @@ import java.net.SocketException; import java.util.Enumeration; import java.util.Properties; +import org.junit.Assert; import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.annotations.BrowserFactory; +import com.vaadin.testbench.annotations.RunLocally; import com.vaadin.testbench.annotations.RunOnHub; import com.vaadin.testbench.parallel.Browser; @@ -45,8 +47,9 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { * */ public static final String SCREENSHOT_DIRECTORY = "com.vaadin.testbench.screenshot.directory"; - private static final String RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.runLocally"; private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname"; + private static final String RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.runLocally"; + private static final String ALLOW_RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.allowRunLocally"; private static final String PORT_PROPERTY = "com.vaadin.testbench.deployment.port"; private static final String DEPLOYMENT_PROPERTY = "com.vaadin.testbench.deployment.url"; private static final String HUB_URL = "com.vaadin.testbench.hub.url"; @@ -77,6 +80,18 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { } } + @Override + public void setup() throws Exception { + String allowRunLocally = getProperty(ALLOW_RUN_LOCALLY_PROPERTY); + if ((allowRunLocally == null || !allowRunLocally.equals("" + true)) + && getClass().getAnnotation(RunLocally.class) != null) { + Assert.fail("@RunLocally annotation is not allowed by default in framework tests. " + + "See file uitest/eclipse-run-selected-test.properties for more information."); + } + + super.setup(); + } + private static DesiredCapabilities getRunLocallyCapabilities() { Browser localBrowser; try { diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java index f401e0613b..e059dea78d 100644 --- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java @@ -340,7 +340,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { */ @After public void checkCompareFailures() throws IOException { - if (!screenshotFailures.isEmpty()) { + if (screenshotFailures != null && !screenshotFailures.isEmpty()) { throw new IOException( "The following screenshots did not match the reference: " + screenshotFailures.toString()); diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoDefaultCaptionWidth.java b/uitest/src/com/vaadin/tests/themes/valo/ValoDefaultCaptionWidth.java new file mode 100644 index 0000000000..6ef585cc12 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoDefaultCaptionWidth.java @@ -0,0 +1,29 @@ +/* + * 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.themes.valo; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.components.colorpicker.DefaultCaptionWidth; + +/** + * Test for color picker with default caption. + * + * @author Vaadin Ltd + */ +@Theme("valo") +public class ValoDefaultCaptionWidth extends DefaultCaptionWidth { + +} diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoDefaultCaptionWidthTest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoDefaultCaptionWidthTest.java new file mode 100644 index 0000000000..7651b641de --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoDefaultCaptionWidthTest.java @@ -0,0 +1,56 @@ +/* + * 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.themes.valo; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ColorPickerElement; +import com.vaadin.tests.components.colorpicker.DefaultCaptionWidthTest; + +/** + * Test for default caption behavior in color picker using Valo theme. + * + * @author Vaadin Ltd + */ +public class ValoDefaultCaptionWidthTest extends DefaultCaptionWidthTest { + + @Override + @Test + public void setDefaultCaption_sizeAndCaptionAreNotSet_pickerGetsStyle() { + super.setDefaultCaption_sizeAndCaptionAreNotSet_pickerGetsStyle(); + int width = $(ColorPickerElement.class).first().getSize().getWidth(); + // Make sure that implicit width is less than one that will be + // explicitly set by the test + assertThat("Width of color picker is overriden by " + + "default caption feature", width, is(lessThan(148))); + } + + @Override + @Test + public void setDefaultCaption_explicitSizeIsSet_pickerNoCaptionStyle() { + super.setDefaultCaption_explicitSizeIsSet_pickerNoCaptionStyle(); + int width = $(ColorPickerElement.class).first().getSize().getWidth(); + // Width should be 150px but let's just check that it's not which is + // used when default caption is used and at least >= 150-1 + assertThat("Width of color picker is overriden by " + + "default caption feature", width, is(greaterThan(149))); + } +} |