diff options
author | Jouni Koivuviita <jouni@vaadin.com> | 2014-06-16 10:29:28 +0300 |
---|---|---|
committer | Jouni Koivuviita <jouni@vaadin.com> | 2014-06-16 10:30:24 +0300 |
commit | 7a92b54724133328998e7c7178b5c298bc88fcd0 (patch) | |
tree | 54f340a8ee21e0407fe790e1113881ed947de3cc /uitest | |
parent | 7a4d0003e9bb6fd920bb879eaff1c24cd6f1f3e7 (diff) | |
parent | ccdc34051d6c74292ce981f66c31c160620a04da (diff) | |
download | vaadin-framework-7a92b54724133328998e7c7178b5c298bc88fcd0.tar.gz vaadin-framework-7a92b54724133328998e7c7178b5c298bc88fcd0.zip |
Merge branch 'master' into valo
Conflicts:
build.properties
Change-Id: I2477f2b420506d1b41d29d9bb1e361d66bedb68d
Diffstat (limited to 'uitest')
116 files changed, 4809 insertions, 2642 deletions
diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyle.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyle.java new file mode 100644 index 0000000000..1a15e7c5ae --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyle.java @@ -0,0 +1,74 @@ +/* + * 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.abstractcomponent; + +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.Label; +import com.vaadin.ui.TextField; + +public class PrimaryStyle extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + // Use a set of three common components as a test. + final Label label = new Label("Test Label"); + label.setPrimaryStyleName("initial"); + label.setStyleName("state"); + addComponent(label); + + final Button button = new Button("Test Button"); + button.setPrimaryStyleName("initial"); + button.setStyleName("state"); + addComponent(button); + + final TextField tf = new TextField("Test TextField"); + tf.setPrimaryStyleName("initial"); + tf.setStyleName("state"); + addComponent(tf); + + Button updateButton = new Button("Update styles", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + label.setPrimaryStyleName("updated"); + label.setStyleName("correctly"); + + button.setPrimaryStyleName("updated"); + button.setStyleName("correctly"); + + tf.setPrimaryStyleName("updated"); + tf.setStyleName("correctly"); + } + }); + updateButton.setId("update-button"); + addComponent(updateButton); + } + + @Override + protected String getTestDescription() { + return "Test that setPrimaryStyleName followed by setStyleName results in correct class names."; + } + + @Override + protected Integer getTicketNumber() { + return 12190; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyleTest.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyleTest.java new file mode 100644 index 0000000000..ce99c4a3d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/PrimaryStyleTest.java @@ -0,0 +1,51 @@ +/* + * 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.abstractcomponent; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import com.vaadin.testbench.elements.ButtonElement; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PrimaryStyleTest extends MultiBrowserTest { + + @Test + public void testStyleNames() { + openTestURL(); + + // Verify the initial class names for all three components. + List<WebElement> initialElements = driver.findElements(By + .className("initial-state")); + assertThat(initialElements, hasSize(3)); + + // Click on a button that updates the styles. + $(ButtonElement.class).id("update-button").click(); + + // Verify that the class names where updated as expected. + List<WebElement> updatedElements = driver.findElements(By.className("updated-correctly")); + assertThat(updatedElements, hasSize(initialElements.size())); + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java new file mode 100644 index 0000000000..c50e483c44 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java @@ -0,0 +1,64 @@ +/* + * 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.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.VerticalLayout; + +/** + * Test UI for issue #11929 where ComboBox suggestion popup hides the ComboBox + * itself obscuring the text input field. + * + * @author Vaadin Ltd + */ +public class ComboBoxOnSmallScreen extends AbstractTestUI { + + private static final String PID = "captionPID"; + + @Override + protected void setup(VaadinRequest request) { + addComponents(createComboBox(), createComboBox()); + VerticalLayout vl = getLayout(); + vl.setHeight(300, Unit.PIXELS); + vl.setComponentAlignment(vl.getComponent(1), Alignment.BOTTOM_LEFT); + } + + @Override + protected String getTestDescription() { + return "Combobox hides what you are typing on small screen"; + } + + @Override + protected Integer getTicketNumber() { + return 11929; + } + + private ComboBox createComboBox() { + ComboBox cb = new ComboBox(); + cb.addContainerProperty(PID, String.class, ""); + cb.setItemCaptionPropertyId(PID); + + for (int i = 1; i < 21; ++i) { + final String v = "Item #" + i; + cb.getItem(cb.addItem()).getItemProperty(PID).setValue(v); + } + + return cb; + } +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java new file mode 100644 index 0000000000..c45168aa6d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.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.combobox; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebDriver.Window; +import org.openqa.selenium.WebElement; + +import com.vaadin.client.ui.VFilterSelect; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * ComboBox suggestion popup should not obscure the text input box. + * + * @author Vaadin Ltd + */ +public class ComboBoxOnSmallScreenTest extends MultiBrowserTest { + + private static final Dimension TARGETSIZE = new Dimension(600, 300); + private static final String POPUPCLASSNAME = VFilterSelect.CLASSNAME + + "-suggestpopup"; + + @Override + public void setup() throws Exception { + super.setup(); + + openTestURL(); + + getWindow().setSize(TARGETSIZE); + } + + @Test + public void testUpperSuggestionPopupOverlayPosition() { + ComboBoxElement cb = getComboBoxAndOpenPopup(0); + assertOverlayPosition(cb, getPopup()); + } + + @Test + public void testUpperSuggestionPopupOverlaySize() { + ComboBoxElement cb = getComboBoxAndOpenPopup(0); + assertOverlaySize(cb, getPopup()); + } + + @Test + public void testLowerSuggestionPopupOverlayPosition() { + ComboBoxElement cb = getComboBoxAndOpenPopup(1); + assertOverlayPosition(cb, getPopup()); + } + + @Test + public void testLowerSuggestionPopupOverlaySize() { + ComboBoxElement cb = getComboBoxAndOpenPopup(1); + assertOverlaySize(cb, getPopup()); + } + + private void assertOverlayPosition(WebElement combobox, WebElement popup) { + final int popupTop = popup.getLocation().y; + final int popupBottom = popupTop + popup.getSize().getHeight(); + final int cbTop = combobox.getLocation().y; + final int cbBottom = cbTop + combobox.getSize().getHeight(); + + assertThat("Popup overlay does not overlap with the textbox", + popupTop >= cbBottom || popupBottom <= cbTop, is(true)); + } + + private void assertOverlaySize(WebElement combobox, WebElement popup) { + final int popupTop = popup.getLocation().y; + final int popupBottom = popupTop + popup.getSize().getHeight(); + final int rootHeight = findElement(By.tagName("body")).getSize().height; + + assertThat("Popup overlay inside the viewport", popupTop < 0 + || popupBottom > rootHeight, is(false)); + } + + private ComboBoxElement getComboBoxAndOpenPopup(int comboboxIndex) { + ComboBoxElement cb = $(ComboBoxElement.class).get(comboboxIndex); + cb.openPopup(); + return cb; + } + + private WebElement getPopup() { + return findElement(By.className(POPUPCLASSNAME)); + } + + private Window getWindow() { + return getDriver().manage().window(); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html deleted file mode 100644 index 5e412c3aad..0000000000 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html +++ /dev/null @@ -1,148 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888" /> -<title>FormTooltips</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">FormTooltips</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.form.FormTooltips?restartApplication</td> - <td></td> -</tr> -<!--first name tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Fields own tooltip</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--first name caption tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Fields own tooltip</td> -</tr> -<tr> - <td>mouseMove</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--Form should not have a description tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td> - <td>-1000</td> -</tr> -<!--Form error message should not have a tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td> - <td>-1000</td> -</tr> -<!--last name should have no tooltip--> -<tr> - <td>mouseMove</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--last name caption should have no tooltip--> -<tr> - <td>mouseMove</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java index b70f66c710..6e823204e9 100644 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java @@ -31,6 +31,7 @@ public class FormTooltips extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { final Form form = new Form(); + form.setId("tooltipForm"); form.setDescription("Some description"); form.setItemDataSource(new BeanItem<Person>(new Person("foo", "bar", "baz", 12, Sex.MALE, null)), Arrays.asList(new String[] { diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java new file mode 100644 index 0000000000..df18d4082d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.form; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.FormElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.TooltipTest; + +public class FormTooltipsTest extends TooltipTest { + + @Test + public void testTooltipConfiguration() throws Exception { + openTestURL(); + // first name tooltip + + WebElement fieldElement = $(FormElement.class).first() + .$(TextFieldElement.class).first(); + checkTooltip(fieldElement, "Fields own tooltip"); + + moveToRoot(); + Thread.sleep(1000); + checkTooltipNotPresent(); + + // first name caption tooltip + checkTooltip( + $(FormElement.class).first().findElement( + By.className("v-caption")), "Fields own tooltip"); + + moveToRoot(); + Thread.sleep(1000); + checkTooltipNotPresent(); + + // Form should not have a description tooltip + checkTooltip($(FormElement.class).first(), null); + + // Form error message should not have a tooltip + checkTooltip(By.className("v-form-errormessage"), null); + + // last name should have no tooltip + checkTooltip($(TextFieldElement.class).get(1), null); + + // last name caption should have no tooltip + checkTooltip( + $(FormElement.class).first() + .findElements(By.className("v-caption")).get(1), null); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java new file mode 100644 index 0000000000..c20148743a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatio.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +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.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; + +public class GridLayoutExpandRatio extends AbstractTestUI { + HorizontalLayout layout; + GridLayout gridLayout; + GridLayout gridLayout2; + private static final int ROWS = 5; + private static final int COLS = 5; + private Label[][] labels; + + @Override + protected void setup(VaadinRequest request) { + + labels = new Label[ROWS][COLS]; + layout = new HorizontalLayout(); + gridLayout = new GridLayout(ROWS, COLS); + layout.setImmediate(true); + gridLayout.setImmediate(true); + gridLayout2 = new GridLayout(4, 4); + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + Label label = new Label("Slot " + i + " " + j); + label.setImmediate(true); + labels[i][j] = label; + gridLayout.addComponent(label, j, i); + if (!(i == 2 || j == 2)) { + Label label2 = new Label("Slot " + i + " " + j); + gridLayout2.addComponent(label2); + } + } + } + gridLayout.setHeight("500px"); + gridLayout.setWidth("500px"); + gridLayout.setSpacing(true); + + gridLayout2.setHeight("500px"); + gridLayout2.setWidth("500px"); + gridLayout2.setSpacing(true); + addComponent(layout); + HorizontalLayout space = new HorizontalLayout(); + space.setWidth("100px"); + layout.addComponent(gridLayout); + layout.addComponent(space); + layout.addComponent(gridLayout2); + + setExpandRatio(); + addComponent(new Button("Hide/show both middle Column and row", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + hideComponetns(); + } + })); + } + + private void hideComponetns() { + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + if (i == 2 || j == 2) { + if (labels[i][j].isVisible()) { + labels[i][j].setVisible(false); + } else { + labels[i][j].setVisible(true); + } + } + } + } + } + + private void setExpandRatio() { + gridLayout.setRowExpandRatio(2, 5); + gridLayout2.setRowExpandRatio(1, 5); + } + + @Override + protected Integer getTicketNumber() { + return 8855; + } + + @Override + protected String getTestDescription() { + return "If row/column doesn't have elements but have an expand ratio set, it should be shown as a empty row/column"; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java new file mode 100644 index 0000000000..7d5ad1fbc4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +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.GridLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutExpandRatioTest extends MultiBrowserTest { + @Test + public void gridLayoutExpandRatioTest() { + openTestURL(); + GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); + GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); + ButtonElement hidingButton = $(ButtonElement.class).get(0); + hidingButton.click(); + List<WebElement> slots5x5 = gridLayout5x5.findElements(By + .className("v-gridlayout-slot")); + List<WebElement> slots4x4 = gridLayout4x4.findElements(By + .className("v-gridlayout-slot")); + assertEquals("Different amount of slots", slots5x5.size(), + slots4x4.size()); + for (int i = 0; i < slots5x5.size(); i++) { + WebElement compared = slots5x5.get(i); + WebElement actual = slots4x4.get(i); + assertEquals("Different top coordinate for element " + i, + compared.getCssValue("top"), actual.getCssValue("top")); + assertEquals("Different left coordinate for element " + i, + compared.getCssValue("left"), actual.getCssValue("left")); + } + } +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java new file mode 100644 index 0000000000..16b3742c64 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCells.java @@ -0,0 +1,146 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import java.util.Random; + +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.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class GridLayoutHideMiddleCells extends AbstractTestUI { + GridLayout gridLayout; + GridLayout gridLayout2; + + @Override + protected void setup(VaadinRequest request) { + final int ROWS = 5; + final int COLS = 5; + + final Label[][] labels = new Label[ROWS][COLS]; + VerticalLayout mainLayout = new VerticalLayout(); + HorizontalLayout horLayout = new HorizontalLayout(); + gridLayout = new GridLayout(ROWS, COLS); + gridLayout2 = new GridLayout(4, 4); + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + Label label = new Label("Slot " + i + " " + j); + labels[i][j] = label; + gridLayout.addComponent(label); + if (!(i == 2 || j == 2)) { + Label label2 = new Label("Slot " + i + " " + j); + gridLayout2.addComponent(label2); + } + } + } + setContent(mainLayout); + gridLayout.setHeight("500px"); + gridLayout.setWidth("500px"); + gridLayout.setSpacing(true); + + addComponent(gridLayout); + addComponent(gridLayout2); + mainLayout.addComponent(horLayout); + gridLayout2.setHeight("500px"); + gridLayout2.setWidth("500px"); + gridLayout2.setSpacing(true); + horLayout.addComponent(gridLayout); + horLayout.addComponent(gridLayout2); + + mainLayout.addComponent(new Button( + "Hide/show both middle Column and row", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (int i = 0; i < ROWS; i++) { + for (int j = 0; j < COLS; j++) { + if (j == 2 || i == 2) { + if (labels[i][j].isVisible()) { + labels[i][j].setVisible(false); + } else { + labels[i][j].setVisible(true); + } + } + } + } + } + })); + mainLayout.addComponent(new Button("Hide/show middle Column", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (int i = 0; i < ROWS; i++) { + if (labels[i][2].isVisible()) { + labels[i][2].setVisible(false); + } else { + labels[i][2].setVisible(true); + } + } + } + })); + mainLayout.addComponent(new Button("Hide/show middle Row", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (int j = 0; j < COLS; j++) { + if (labels[2][j].isVisible()) { + labels[2][j].setVisible(false); + } else { + labels[2][j].setVisible(true); + } + } + } + + })); + mainLayout.addComponent(new Button("Hide Random button", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + // TODO Auto-generated method stub + Random rand = new Random(); + int i = rand.nextInt(ROWS); + int j = rand.nextInt(COLS); + if (labels[i][j].isVisible()) { + labels[i][j].setVisible(false); + } else { + labels[i][j].setVisible(true); + } + } + })); + } + + @Override + protected Integer getTicketNumber() { + return 8855; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Changing the number of visible fields a GridLayout with spacing should not cause additional empty space on the place of invisible fields"; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java new file mode 100644 index 0000000000..d0225275f7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.gridlayout; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +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.GridLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutHideMiddleCellsTest extends MultiBrowserTest { + @Test + public void gridLayoutInvisibleElementsTest() { + openTestURL(); + GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); + GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); + ButtonElement hidingButton = $(ButtonElement.class).get(0); + hidingButton.click(); + List<WebElement> slots5x5 = gridLayout5x5.findElements(By + .className("v-gridlayout-slot")); + List<WebElement> slots4x4 = gridLayout4x4.findElements(By + .className("v-gridlayout-slot")); + assertEquals("Different amount of slots", slots5x5.size(), + slots4x4.size()); + + for (int i = 0; i < slots5x5.size(); i++) { + assertEquals("Different left coordinate for element " + i, slots5x5 + .get(i).getCssValue("left"), + slots4x4.get(i).getCssValue("left")); + } + for (int i = 0; i < slots5x5.size(); i++) { + assertEquals("Different top coordinate for element " + i, slots5x5 + .get(i).getCssValue("top"), + slots4x4.get(i).getCssValue("top")); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html b/uitest/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html deleted file mode 100644 index f7c57baf1f..0000000000 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuBarToolTips.html +++ /dev/null @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.menubar.MenuBarToolTips?restartApplication</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item0</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>File menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item0</td> - <td>18,11</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VOverlay[0]/VMenuBar[0]#item0</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>File - Foo menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/domChild[1]</td> - <td>830,200</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item1</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Edit menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/domChild[1]</td> - <td>625,184</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VMenuBar[0]#item1</td> - <td>9,6</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VOverlay[0]/VMenuBar[0]#item1</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>Edit - Bar menu</td> -</tr> -<tr> - <td>mouseOut</td> - <td>vaadin=runcomvaadintestscomponentsmenubarMenuBarToolTips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdge.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdge.java new file mode 100644 index 0000000000..4e42d97925 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdge.java @@ -0,0 +1,96 @@ +/* + * 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.menubar; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Component; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.Command; +import com.vaadin.ui.MenuBar.MenuItem; +import com.vaadin.ui.VerticalLayout; + +/** + * Test to see if tooltips will render in the correct locations near the edges. + * + * @author Vaadin Ltd + */ +public class MenuBarTooltipsNearEdge extends AbstractTestUI { + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + VerticalLayout vlayout = new VerticalLayout(); + vlayout.setSizeFull(); + vlayout.addComponent(buildMenu("Menu")); + vlayout.setComponentAlignment(vlayout.getComponent(0), + Alignment.BOTTOM_RIGHT); + setContent(vlayout); + + getTooltipConfiguration().setOpenDelay(0); + getTooltipConfiguration().setQuickOpenDelay(0); + getTooltipConfiguration().setCloseTimeout(1000); + + } + + private Component buildMenu(String label) { + MenuBar menu = new MenuBar(); + MenuItem item = menu.addItem(label, null); + + item.addItem("Item 1", null).setDescription("TOOLTIP 1"); + item.addItem("Item 2", null).setDescription("TOOLTIP 2"); + item.addItem("Item 3", null).setDescription("TOOLTIP 3"); + item.addItem("Item 4", null).setDescription("TOOLTIP 4"); + + return menu; + } + + private Command buildCommand() { + Command command = new Command() { + + @Override + public void menuSelected(MenuItem selectedItem) { + + } + }; + return command; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Menu item tooltips should not abscure other menu items"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12870; + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java new file mode 100644 index 0000000000..3cfe30a991 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java @@ -0,0 +1,64 @@ +/* + * 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.menubar; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test to see if tooltips will render in the correct locations near the edges. + * + * @author Vaadin Ltd + */ +public class MenuBarTooltipsNearEdgeTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // Tooltip tests work unreliably on IE due to an issue with the + // WebDriver (see #13854) + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + return browsers; + }; + + @Test + public void testTooltipLocation() { + openTestURL(); + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + WebElement menu = $(MenuBarElement.class).first().getWrappedElement(); + Coordinates menuLocation = ((Locatable) menu).getCoordinates(); + mouse.click(menuLocation); + mouse.mouseMove(menuLocation, 5, -40); + WebElement tooltip = getTooltipElement(); + assertThat(tooltip.getLocation().x, is(lessThan(menuLocation.onPage().x + - tooltip.getSize().getWidth()))); + + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java new file mode 100644 index 0000000000..2c9d43290f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.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.menubar; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.Command; +import com.vaadin.ui.MenuBar.MenuItem; + +/** + * Test to see if tooltips on menu items obscure other items on the menu. + * + * @author Vaadin Ltd + */ +public class MenuTooltip extends AbstractTestUI { + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + addComponent(buildMenu()); + + getTooltipConfiguration().setOpenDelay(2000); + + } + + private Component buildMenu() { + MenuBar menu = new MenuBar(); + MenuItem item = menu.addItem("Menu", null); + + item.addItem("Item 1", null).setDescription("TOOLTIP 1"); + item.addItem("Item 2", null).setDescription("TOOLTIP 2"); + item.addItem("Item 3", null).setDescription("TOOLTIP 3"); + item.addItem("Item 4", null).setDescription("TOOLTIP 4"); + + return menu; + } + + private Command buildCommand() { + Command command = new Command() { + + @Override + public void menuSelected(MenuItem selectedItem) { + + } + }; + return command; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Menu item tooltips should not abscure other menu items"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 13914; + } +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java new file mode 100644 index 0000000000..bb8f87daaa --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java @@ -0,0 +1,68 @@ +/* + * 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.menubar; + +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 java.util.List; + +import org.junit.Test; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test to see if tooltips on menu items obscure other items on the menu. + * + * @author Vaadin Ltd + */ +public class MenuTooltipTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return getBrowsersExcludingIE(); + } + + @Test + public void testToolTipDelay() throws InterruptedException { + openTestURL(); + + Coordinates elementCoordinates = getCoordinates($(MenuBarElement.class).first()); + + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + + mouse.click(elementCoordinates); + mouse.mouseMove(elementCoordinates, 15, 40); + + sleep(1000); + + assertThat(getTooltipElement().getLocation().getX(), + is(lessThan(-1000))); + + sleep(3000); + + assertThat(getTooltipElement().getLocation().getX(), + is(greaterThan(elementCoordinates.onPage().getX()))); + assertThat(getTooltipElement().getText(), is("TOOLTIP 1")); + } +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java new file mode 100644 index 0000000000..233049b0ba --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicator.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * + */ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class TooltipOnRequiredIndicator extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + + TextField inVertical = new TextField(); + inVertical.setRequired(true); + inVertical.setRequiredError("Vertical layout tooltip"); + inVertical.setCaption("Vertical layout caption"); + inVertical.setId("verticalField"); + + layout.addComponent(inVertical); + addComponent(layout); + + HorizontalLayout horizontalLayout = new HorizontalLayout(); + + TextField inHorizontal = new TextField(); + inHorizontal.setRequired(true); + inHorizontal.setRequiredError("Horizontal layout tooltip"); + inHorizontal.setCaption("Horizontal layout caption"); + inHorizontal.setId("horizontalField"); + + horizontalLayout.addComponent(inHorizontal); + layout.addComponent(horizontalLayout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Show tooltip for caption and required indicator"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 10046; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java new file mode 100644 index 0000000000..815c00bfac --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/TooltipOnRequiredIndicatorTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.orderedlayout; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.HorizontalLayoutElement; +import com.vaadin.testbench.elements.VerticalLayoutElement; +import com.vaadin.tests.tb3.TooltipTest; + +public class TooltipOnRequiredIndicatorTest extends TooltipTest { + + @Test + public void testTooltipOnRequiredIndicator() throws Exception { + openTestURL(); + + // gwt-uid-* are not stable across browsers etc. so need to look them up + + // caption + checkTooltip( + $(VerticalLayoutElement.class).get(1).findElement( + By.className("v-captiontext")), + "Vertical layout tooltip"); + // required indicator + checkTooltip(By.className("v-required-field-indicator"), + "Vertical layout tooltip"); + + // caption + checkTooltip( + $(HorizontalLayoutElement.class).first().findElement( + By.className("v-captiontext")), + "Horizontal layout tooltip"); + // required indicator + checkTooltip( + $(HorizontalLayoutElement.class).first().findElement( + By.className("v-required-field-indicator")), + "Horizontal layout tooltip"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html index 806e7d1b44..6014f557e7 100644 --- a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html +++ b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html @@ -64,7 +64,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> + <td>-5000</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html index 2df9fb678c..4c2dec9784 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html +++ b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html @@ -46,7 +46,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -77,7 +77,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -108,7 +108,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Cell and row tooltips--> <tr> @@ -145,7 +145,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -176,7 +176,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -207,7 +207,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Row and Component tooltips--> <tr> @@ -249,7 +249,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -280,7 +280,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -311,7 +311,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Row tooltips--> <tr> @@ -348,7 +348,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--Button tooltip--> <tr> @@ -379,7 +379,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> <!--TextField tooltip--> <tr> @@ -410,7 +410,7 @@ <tr> <td>assertElementPositionLeft</td> <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> - <td>-1000</td> + <td>-5000</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html deleted file mode 100644 index 338e4a2c5b..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html +++ /dev/null @@ -1,146 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>TooltipConfiguration</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">TooltipConfiguration</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.ui.TooltipConfiguration?restartApplication</td> - <td></td> -</tr> -<!--Short close delay--> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>0</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>This is a short tooltip</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td></td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-1000</td> -</tr> -<!--Long close delay--> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>3000</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td>0,0</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>This is a short tooltip</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td></td> -</tr> -<tr> - <td>assertElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>60,9</td> -</tr> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td> - <td>0</td> -</tr> -<!--Max width 500--> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertElementWidth</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>500</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td></td> -</tr> -<!--Max width 100--> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SMax width</td> - <td>100</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td> - <td>0,0</td> -</tr> -<tr> - <td>mouseMoveAt</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertElementWidth</td> - <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>100</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java index 4d201d2a1a..eeea91b638 100644 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java @@ -32,8 +32,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { closeTimeout.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setCloseTimeout( - (Integer) closeTimeout.getConvertedValue()); + if (closeTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setCloseTimeout( + (Integer) closeTimeout.getConvertedValue()); + } } }); maxWidth = createIntegerTextField("Max width", @@ -41,8 +43,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { maxWidth.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setMaxWidth( - (Integer) maxWidth.getConvertedValue()); + if (maxWidth.getConvertedValue() != null) { + getTooltipConfiguration().setMaxWidth( + (Integer) maxWidth.getConvertedValue()); + } } }); openDelay = createIntegerTextField("Open delay", @@ -50,8 +54,10 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { openDelay.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setOpenDelay( - (Integer) openDelay.getConvertedValue()); + if (openDelay.getConvertedValue() != null) { + getTooltipConfiguration().setOpenDelay( + (Integer) openDelay.getConvertedValue()); + } } }); @@ -61,8 +67,11 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { .addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setQuickOpenDelay( - (Integer) quickOpenDelay.getConvertedValue()); + if (quickOpenDelay.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenDelay( + (Integer) quickOpenDelay + .getConvertedValue()); + } } }); @@ -72,8 +81,11 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { .addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - getTooltipConfiguration().setQuickOpenTimeout( - (Integer) quickOpenTimeout.getConvertedValue()); + if (quickOpenTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenTimeout( + (Integer) quickOpenTimeout + .getConvertedValue()); + } } }); @@ -91,6 +103,8 @@ public class TooltipConfiguration extends AbstractTestUIWithLog { tf.setConverter(Integer.class); tf.setImmediate(true); tf.setConvertedValue(initialValue); + // makes TB3 tests simpler - no "null" added when clearing a field + tf.setNullRepresentation(""); return tf; } diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java new file mode 100644 index 0000000000..f3e7554579 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import java.util.NoSuchElementException; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TooltipConfigurationTest extends MultiBrowserTest { + + private org.openqa.selenium.By tooltipBy = By + .vaadin("Root/VTooltip[0]/FlowPanel[0]/domChild[1]"); + + @Test + public void testTooltipConfiguration() throws Exception { + openTestURL(); + + WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); + WebElement closeTimeout = vaadinElementById("Close timeout"); + WebElement shortTooltip = vaadinElementById("shortTooltip"); + WebElement longTooltip = vaadinElementById("longTooltip"); + WebElement maxWidth = vaadinElementById("Max width"); + + selectAndType(closeTimeout, "0"); + testBenchElement(shortTooltip).showTooltip(); + waitForElementToBePresent(tooltipBy); + Assert.assertEquals("This is a short tooltip", getTooltip().getText()); + + new Actions(getDriver()).moveToElement(uiRoot, 0, 0).click().perform(); + // uiRoot.click(); + checkTooltipNotPresent(); + + selectAndType(closeTimeout, "3000"); + moveMouseToTopLeft(uiRoot); + testBenchElement(shortTooltip).showTooltip(); + waitForElementToBePresent(tooltipBy); + WebElement tooltip2 = getTooltip(); + Assert.assertEquals("This is a short tooltip", tooltip2.getText()); + + uiRoot.click(); + // assert that tooltip is present + getTooltip(); + selectAndType(closeTimeout, "0"); + testBenchElement(longTooltip).showTooltip(); + waitForElementToBePresent(tooltipBy); + Assert.assertEquals(500, getTooltip().getSize().getWidth()); + + uiRoot.click(); + selectAndType(maxWidth, "100"); + moveMouseToTopLeft(uiRoot); + testBenchElement(longTooltip).showTooltip(); + Assert.assertEquals(100, getTooltip().getSize().getWidth()); + } + + private WebElement getTooltip() { + return getDriver().findElement(tooltipBy); + } + + private void checkTooltipNotPresent() { + try { + WebElement tooltip = getTooltip(); + if (!"".equals(tooltip.getText()) + || tooltip.getLocation().getX() > -999) { + Assert.fail("Found tooltip that shouldn't be visible: " + + tooltip.getText() + " at " + tooltip.getLocation()); + } + } catch (NoSuchElementException e) { + Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools"); + } + } + + private void selectAndType(WebElement element, String value) { + // select and replace text + element.clear(); + // if null representation not set as "", need to move cursor to end and + // remove text "null" + // element.sendKeys("" + Keys.BACK_SPACE + Keys.BACK_SPACE + // + Keys.BACK_SPACE + Keys.BACK_SPACE); + element.sendKeys(value + Keys.ENTER); + } + + private void moveMouseToTopLeft(WebElement element) { + new Actions(getDriver()).moveToElement(element, 0, 0).perform(); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java index 06fb659d4a..412fd3049d 100644 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java @@ -74,10 +74,6 @@ public class TooltipInWindowTest extends MultiBrowserTest { } - private WebElement getTooltipElement() { - return getDriver().findElement(By.className("v-tooltip-text")); - } - private WebElement getTooltipContainerElement() { return getDriver().findElement(By.className("v-tooltip")); } diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeight.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeight.java new file mode 100644 index 0000000000..1c3acbec8d --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeight.java @@ -0,0 +1,50 @@ +/* + * 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.Theme; +import com.vaadin.server.Responsive; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Label; + +@Theme("tests-responsive") +public class ResponsiveWidthAndHeight extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + CssLayout layout = new CssLayout(); + layout.addStyleName("width-and-height"); + layout.setSizeFull(); + setContent(layout); + Responsive.makeResponsive(layout); + + layout.addComponent(new Label( + "Resize the browser window in both dimensions to see the background color change.")); + } + + @Override + protected String getTestDescription() { + return "The CssLayout with both width-range and height-range defined"; + } + + @Override + protected Integer getTicketNumber() { + return 13587; + } +} diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeightTest.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeightTest.java new file mode 100644 index 0000000000..8086457c24 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveWidthAndHeightTest.java @@ -0,0 +1,64 @@ +/* + * 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 static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.CssLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ResponsiveWidthAndHeightTest extends MultiBrowserTest { + + @Before + public void setUp() throws Exception { + // We need this in order to ensure that the initial width-range is + // width: 600px- and height: 500px- + testBench().resizeViewPortTo(1024, 768); + } + + @Test + public void testWidthAndHeightRanges() throws Exception { + openTestURL(); + + // IE sometimes has trouble waiting long enough. + new WebDriverWait(getDriver(), 30).until(ExpectedConditions + .presenceOfElementLocated(By + .cssSelector(".v-csslayout-width-and-height"))); + + // Verify both width-range and height-range. + assertEquals("600px-", + $(CssLayoutElement.class).first().getAttribute("width-range")); + assertEquals("500px-", + $(CssLayoutElement.class).first().getAttribute("height-range")); + + // Resize + testBench().resizeViewPortTo(550, 450); + + // Verify updated width-range and height-range. + assertEquals("0-599px", + $(CssLayoutElement.class).first().getAttribute("width-range")); + assertEquals("0-499px", + $(CssLayoutElement.class).first().getAttribute("height-range")); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java deleted file mode 100644 index c96d542a4c..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/AbstractLayoutTests.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import com.vaadin.ui.Layout; - -public abstract class AbstractLayoutTests { - - protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png"; - protected static final String CALENDAR_32_PNG = "../runo/icons/32/calendar.png"; - protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png"; - protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png"; - - abstract protected Layout getCaptionsTests(); - - abstract protected Layout getIconsTests(); - - abstract protected Layout getRequiredErrorIndicatorsTests(); - - abstract protected Layout getAlignmentTests(); - - abstract protected Layout getExpandRatiosTests(); - - abstract protected Layout getMarginSpacingTests(); - - abstract protected Layout getComponentAddReplaceMoveTests(); - - abstract protected Layout getComponentSizingTests(); - - abstract protected Layout getLayoutSizingTests(); - -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java new file mode 100644 index 0000000000..7ea8739cf4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMove.java @@ -0,0 +1,109 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseAddReplaceMove extends BaseLayoutTestUI { + + /** + * @param layoutClass + */ + public BaseAddReplaceMove(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + // Set undefined height to avoid expanding + l2.setHeight(null); + // extra layout from which components will be moved + final HorizontalLayout source = new HorizontalLayout(); + source.addComponent(new Label("OTHER LABEL 1")); + source.addComponent(new Label("OTHER LABEL 2")); + + final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c3 = new Table("TABLE"); + c3.setHeight("100px"); + c3.setWidth("100%"); + + final Button btnAdd = new Button("Test add"); + final Button btnReplace = new Button("Test replace"); + final Button btnMove = new Button("Test move"); + final Button btnRemove = new Button("Test remove"); + + l1.addComponent(btnAdd); + l1.addComponent(btnReplace); + l1.addComponent(btnMove); + l1.addComponent(btnRemove); + + btnAdd.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.addComponent(new TextField()); + } + }); + btnReplace.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.replaceComponent(c1, c3); + } + }); + btnMove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.moveComponentsFrom(source); + } + }); + btnRemove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + l2.removeComponent(c1); + l2.removeComponent(c2); + } + }); + + l2.addComponent(c1); + l2.addComponent(c2); + l2.addComponent(c3); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java new file mode 100644 index 0000000000..73dc39009d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAddReplaceMoveTest.java @@ -0,0 +1,43 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class BaseAddReplaceMoveTest extends MultiBrowserTest { + @Test + public void LayoutAlignment() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "add", "replace", "move", "remove" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.java new file mode 100644 index 0000000000..bfdc53bf7c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignment.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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractOrderedLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +abstract public class BaseAlignment extends BaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + // create two columns of components with different + // alignment. Used to test alignment in layouts + init(); + buildLayout(); + super.setup(request); + } + + public BaseAlignment(Class<? extends AbstractOrderedLayout> layoutClass) { + super(layoutClass); + } + + /** + * Build Layout for test + */ + private void buildLayout() { + for (int i = 0; i < components.length; i++) { + AbstractOrderedLayout layout = null; + try { + layout = (AbstractOrderedLayout) layoutClass.newInstance(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + layout.setHeight("300px"); + layout.setWidth("200px"); + layout.addComponent(components[i]); + layout.setComponentAlignment(components[i], alignments[i]); + if (i < components.length / 2) { + l1.addComponent(layout); + } else { + l2.addComponent(layout); + } + } + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java new file mode 100644 index 0000000000..9dd90a4031 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseAlignmentTest.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseAlignmentTest extends MultiBrowserTest { + + @Test + public void layoutAlignment() throws IOException { + openTestURL(); + compareScreen("alignment"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java new file mode 100644 index 0000000000..37ce77e745 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaption.java @@ -0,0 +1,44 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.TabSheet; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseCaption extends BaseLayoutTestUI { + + /** + * @param layoutClass + */ + public BaseCaption(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + l1.addComponent(createLabelsFields(ComboBox.class, true, "")); + l2.addComponent(createLabelsFields(TabSheet.class, false, "")); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java new file mode 100644 index 0000000000..ed20657e2a --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseCaptionTest.java @@ -0,0 +1,35 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseCaptionTest extends MultiBrowserTest { + @Test + public void LayoutCaption() throws IOException, InterruptedException { + openTestURL(); + compareScreen("caption"); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java new file mode 100644 index 0000000000..d9377c6a8b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizing.java @@ -0,0 +1,38 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseComponentSizing extends BaseLayoutTestUI { + + public BaseComponentSizing(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + getLayoutForLayoutSizing("component"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java new file mode 100644 index 0000000000..252cfcd359 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseComponentSizingTest.java @@ -0,0 +1,45 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class BaseComponentSizingTest extends MultiBrowserTest { + @Test + public void ComponentSizing() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent", + "setSize100Percent" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java new file mode 100644 index 0000000000..34ec7928ff --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIcon.java @@ -0,0 +1,51 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseIcon extends BaseLayoutTestUI { + /** + * @param layoutClass + */ + public BaseIcon(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + l1.addComponent(createLabelsFields(TextField.class, true, "")); + l1.addComponent(createLabelsFields(Label.class, true, "")); + l1.addComponent(createLabelsFields(Button.class, true, "")); + l2.addComponent(createLabelsFields(ComboBox.class, true, "")); + l2.addComponent(createLabelsFields(Link.class, true, "")); + l2.addComponent(createLabelsFields(TabSheet.class, true, "")); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.java new file mode 100644 index 0000000000..9322672eae --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseIconTest.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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseIconTest extends MultiBrowserTest { + + @Test + public void LayoutIcon() throws IOException { + openTestURL(); + compareScreen("icon"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java new file mode 100644 index 0000000000..f21db94f80 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpand.java @@ -0,0 +1,77 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseLayoutExpand extends BaseLayoutTestUI { + + public BaseLayoutExpand(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + class ExpandButton extends Button { + final private AbstractComponent c1; + private AbstractComponent c2; + private float expandComp1; + private float expandComp2; + + public ExpandButton(final AbstractComponent c1, + final AbstractComponent c2, float e1, float e2) { + super(); + this.c1 = c1; + this.c2 = c2; + expandComp1 = e1; + expandComp2 = e2; + setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100); + addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + l2.setExpandRatio(c1, expandComp1); + l2.setExpandRatio(c2, expandComp2); + } + }); + } + } + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + l2.addComponent(t1); + l2.addComponent(t2); + + l1.addComponent(new ExpandButton(t1, t2, 1.0f, 0.0f)); + l1.addComponent(new ExpandButton(t1, t2, 0.5f, 0.50f)); + l1.addComponent(new ExpandButton(t1, t2, .25f, 0.75f)); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java new file mode 100644 index 0000000000..08f5aed808 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutExpandTest.java @@ -0,0 +1,49 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseLayoutExpandTest extends MultiBrowserTest { + + @Test + public void LayoutExpand() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "expand_100_0", "expand_50_50", "expand_25_75" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java new file mode 100644 index 0000000000..e98573d170 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutForSpacingMargin.java @@ -0,0 +1,81 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseLayoutForSpacingMargin extends BaseLayoutTestUI { + /** + * @param layoutClass + */ + public BaseLayoutForSpacingMargin( + Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + l2.addComponent(t1); + l2.setMargin(false); + l2.setSpacing(false); + // Must add something around the hr to avoid the margins collapsing + l2.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + l2.addComponent(t2); + final Button btn1 = new Button("Toggle margin on/off"); + btn1.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + boolean margin = l2.getMargin().hasLeft(); + l2.setMargin(!margin); + + } + }); + final Button btn2 = new Button("Toggle spacing on/off"); + btn2.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + l2.setSpacing(!l2.isSpacing()); + } + }); + l1.addComponent(btn1); + l1.addComponent(btn2); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..46edfec986 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutMarginSpacingTest.java @@ -0,0 +1,42 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class BaseLayoutMarginSpacingTest extends MultiBrowserTest { + + @Test + public void LayoutMarginSpacing() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "marginOnSpaceOff", "marginOnfSpaceOn" }; + ButtonElement marginBtn = $(ButtonElement.class).get(0); + ButtonElement spaceBtn = $(ButtonElement.class).get(1); + marginBtn.click(); + sleep(1000); + compareScreen(states[0]); + spaceBtn.click(); + sleep(1000); + compareScreen(states[1]); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.java new file mode 100644 index 0000000000..61d6f8a362 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutRegErrorTest.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.layouts.layouttester; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseLayoutRegErrorTest extends MultiBrowserTest { + + @Test + public void LayoutRegError() throws IOException { + openTestURL(); + compareScreen("RegError"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java new file mode 100644 index 0000000000..edc0b275d1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizing.java @@ -0,0 +1,40 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseLayoutSizing extends BaseLayoutTestUI { + /** + * @param layoutClass + */ + public BaseLayoutSizing(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + getLayoutForLayoutSizing("layout"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java new file mode 100644 index 0000000000..e97353c989 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutSizingTest.java @@ -0,0 +1,50 @@ +/* + * 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.layouts.layouttester; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class BaseLayoutSizingTest extends MultiBrowserTest { + @Test + public void LayoutSizing() throws IOException, InterruptedException { + openTestURL(); + sleep(500); + compareScreen("initial"); + String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent", + "setSize100Percent" }; + List<ButtonElement> buttons = $(ButtonElement.class).all(); + int index = 0; + // go through all buttons click them and see result + for (ButtonElement btn : buttons) { + btn.click(); + sleep(500); + compareScreen(states[index]); + index++; + } + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java new file mode 100644 index 0000000000..02fcb677cd --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java @@ -0,0 +1,288 @@ +/* + * 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.layouts.layouttester; + +import com.vaadin.server.Resource; +import com.vaadin.server.ThemeResource; +import com.vaadin.server.UserError; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +/** + * + * Base class for Layout tests. + */ +public abstract class BaseLayoutTestUI extends AbstractTestUI { + protected static final String FOLDER_16_PNG = "../icons/runo/16/folder.png"; + protected static final String CALENDAR_32_PNG = "../runo/icons/16/calendar.png"; + protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png"; + protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png"; + public Alignment[] alignments = new Alignment[] { Alignment.TOP_CENTER, + Alignment.TOP_LEFT, Alignment.TOP_RIGHT, Alignment.BOTTOM_CENTER, + Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT, + Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT, + Alignment.MIDDLE_RIGHT }; + + public final String[] CAPTIONS = new String[] { "", + "VeryLongOneWordCaption", + "Very long caption of 50 approximately symbols aaaaaaaaaaaa aaaaaa aaa " }; + Resource[] ICONS = new Resource[] { new ThemeResource(CALENDAR_32_PNG), + new ThemeResource(LOCK_16_PNG), new ThemeResource(GLOBE_16_PNG) }; + public AbstractComponent[] components = new AbstractComponent[alignments.length]; + + protected AbstractOrderedLayout l1; + protected AbstractOrderedLayout l2; + protected Class<? extends AbstractLayout> layoutClass; + protected VerticalLayout mainLayout = new VerticalLayout(); + + public BaseLayoutTestUI(Class<? extends AbstractLayout> layoutClass) { + super(); + fillComponents(); + this.layoutClass = layoutClass; + + } + + protected void init() { + try { + l1 = (AbstractOrderedLayout) layoutClass.newInstance(); + l2 = (AbstractOrderedLayout) layoutClass.newInstance(); + } catch (InstantiationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IllegalAccessException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (layoutClass.equals(HorizontalLayout.class)) { + setLayoutMeasures(l1, l2, "600px", "400px"); + } else if (layoutClass.equals(VerticalLayout.class)) { + setLayoutMeasures(l1, l2, "400px", "400px"); + } else { + setDefaultForVertical(l1, l2); + } + } + + private void fillComponents() { + for (int i = 0; i < components.length; i++) { + String name = "Field" + i; + TextField field = new TextField(); + field.setValue(name); + components[i] = field; + } + } + + protected AbstractLayout createLabelsFields( + Class<? extends AbstractComponent> compType) { + return createLabelsFields(compType, false, null); + } + + protected void getLayoutForLayoutSizing(final String compType) { + + l2.setSpacing(false); + l2.setMargin(false); + + final AbstractComponent c1 = getTestTable(); + c1.setSizeFull(); + final AbstractComponent c2 = getTestTable(); + c2.setSizeFull(); + + class SetSizeButton extends Button { + SetSizeButton(final String size) { + super(); + setCaption("Set size " + size); + addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (compType == "layout") { + l2.setHeight(size); + l2.setWidth(size); + } else if (compType == "component") { + c2.setHeight(size); + c2.setWidth(size); + } else { + } + + } + }); + } + + } + Button btn1 = new SetSizeButton("350px"); + Button btn2 = new SetSizeButton("-1px"); + Button btn3 = new SetSizeButton("75%"); + Button btn4 = new SetSizeButton("100%"); + + l1.addComponent(btn1); + l1.addComponent(btn2); + l1.addComponent(btn3); + l1.addComponent(btn4); + l2.addComponent(c1); + l2.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + l2.addComponent(c2); + l2.setExpandRatio(c1, 0.5f); + l2.setExpandRatio(c2, 0.5f); + + btn2.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Label newLabel = new Label("--- NEW LABEL ---"); + newLabel.setSizeUndefined(); + l2.addComponent(newLabel); + + } + }); + } + + protected Table getTestTable() { + Table t = new Table(); + t.setPageLength(5); + t.addContainerProperty("test", String.class, null); + t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1); + t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); + return t; + } + + protected AbstractLayout createLabelsFields( + Class<? extends AbstractComponent> compType, boolean useIcon, + String ErrorMessage) { + AbstractLayout mainLayout = new VerticalLayout(); + AbstractLayout curLayout = null; + try { + curLayout = layoutClass.newInstance(); + } catch (InstantiationException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IllegalAccessException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + final Component[] components = new Component[CAPTIONS.length]; + + for (int i = 0; i < components.length; i++) { + AbstractComponent comp = null; + try { + comp = compType.newInstance(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + components[i] = comp; + comp.setCaption(CAPTIONS[i]); + if (useIcon) { + comp.setIcon(ICONS[i]); + } + if (ErrorMessage != null) { + if (ErrorMessage.length() == 0) { + comp.setComponentError(new UserError(null)); + } else { + comp.setComponentError(new UserError(ErrorMessage)); + } + } + // if component is a tab sheet add two tabs for it + if (comp instanceof TabSheet) { + comp.setSizeUndefined(); + TabSheet tab = (TabSheet) comp; + tab.addTab(new UndefWideLabel("TAB1"), "TAB1", + new ThemeResource(GLOBE_16_PNG)); + tab.addTab(new UndefWideLabel("TAB2"), "TAB2", null); + } + curLayout.addComponent(comp); + mainLayout.addComponent(curLayout); + } + return mainLayout; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + mainLayout.addComponent(l1); + mainLayout.addComponent(l2); + addComponent(mainLayout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return null; + } + + protected void setLayoutMeasures(AbstractOrderedLayout l1, + AbstractOrderedLayout l2, String w, String h) { + l1.setWidth(w); + l1.setHeight(h); + l2.setWidth(h); + l2.setHeight(w); + } + + protected void setDefaultForVertical(AbstractOrderedLayout l1, + AbstractOrderedLayout l2) { + l1.setWidth("800px"); + l1.setHeight("600px"); + l2.setWidth("800px"); + l2.setHeight("600px"); + } + + protected void setDefaultForHorizontal(AbstractOrderedLayout l1, + AbstractOrderedLayout l2) { + l1.setWidth("600px"); + l1.setHeight("600px"); + l2.setWidth("600px"); + l2.setHeight("600px"); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.java new file mode 100644 index 0000000000..df4053b533 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/BaseRegError.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.layouts.layouttester; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class BaseRegError extends BaseLayoutTestUI { + + public BaseRegError(Class<? extends AbstractLayout> layoutClass) { + super(layoutClass); + } + + @Override + protected void setup(VaadinRequest request) { + init(); + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + + l1.addComponent(createLabelsFields(Label.class, true, "")); + l1.addComponent(createLabelsFields(Button.class, true, "")); + l1.addComponent(createLabelsFields(TabSheet.class, true, "")); + l1.addComponent(createLabelsFields(TextField.class, true, "")); + + l2.addComponent(createLabelsFields(ComboBox.class, true, "")); + l2.addComponent(createLabelsFields(DateField.class, true, "")); + l2.addComponent(createLabelsFields(NativeSelect.class, true, "")); + l2.addComponent(createLabelsFields(CheckBox.class, true, "")); + + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.java new file mode 100644 index 0000000000..2771af01c6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMove.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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class GridAddReplaceMove extends GridBaseLayoutTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + + final HorizontalLayout source = new HorizontalLayout(); + source.addComponent(new Label("OTHER LABEL 1")); + source.addComponent(new Label("OTHER LABEL 2")); + + final AbstractComponent c1 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); + final AbstractComponent c3 = new Table("TABLE"); + c3.setHeight("100px"); + c3.setWidth("100%"); + + final Button btnAdd = new Button("Test add"); + final Button btnReplace = new Button("Test replace"); + final Button btnMove = new Button("Test move"); + final Button btnRemove = new Button("Test remove"); + + layout.addComponent(btnAdd); + layout.addComponent(btnReplace); + layout.addComponent(btnMove); + layout.addComponent(btnRemove); + + btnAdd.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.addComponent(new TextField()); + } + }); + btnReplace.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.replaceComponent(c1, c3); + } + }); + btnMove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.moveComponentsFrom(source); + } + }); + btnRemove.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.removeComponent(c1); + layout.removeComponent(c2); + } + }); + + layout.addComponent(c1); + layout.addComponent(c2); + layout.addComponent(c3); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java new file mode 100644 index 0000000000..f83a6ccf67 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAddReplaceMoveTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridAddReplaceMoveTest extends BaseAddReplaceMoveTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java new file mode 100644 index 0000000000..e061532690 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignment.java @@ -0,0 +1,41 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; + +public class GridAlignment extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + /** + * Build Layout for test + */ + private void buildLayout() { + layout.setColumns(3); + layout.setRows(3); + // layout.setHeight("600px"); + // layout.setWidth("900px"); + for (int i = 0; i < components.length; i++) { + layout.addComponent(components[i]); + layout.setComponentAlignment(components[i], alignments[i]); + } + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java new file mode 100644 index 0000000000..cdc040930b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridAlignmentTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; + +public class GridAlignmentTest extends BaseAlignmentTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java new file mode 100644 index 0000000000..d79c52ccda --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridBaseLayoutTestUI.java @@ -0,0 +1,107 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.layouts.layouttester.BaseLayoutTestUI; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; + +/** + * + * @since + * @author Vaadin Ltd + */ +public abstract class GridBaseLayoutTestUI extends BaseLayoutTestUI { + protected GridLayout layout = new GridLayout(); + + /** + * @param layoutClass + */ + public GridBaseLayoutTestUI() { + super(GridLayout.class); + } + + @Override + protected void setup(VaadinRequest request) { + layout.setMargin(true); + layout.setSizeFull(); + getUI().setContent(layout); + } + + @Override + protected void getLayoutForLayoutSizing(final String compType) { + + layout.setSpacing(false); + layout.setMargin(false); + + final AbstractComponent c1 = getTestTable(); + c1.setSizeFull(); + final AbstractComponent c2 = getTestTable(); + c2.setSizeFull(); + + class SetSizeButton extends Button { + SetSizeButton(final String size) { + super(); + setCaption("Set size " + size); + addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (compType == "layout") { + layout.setHeight(size); + layout.setWidth(size); + } else if (compType == "component") { + c2.setHeight(size); + c2.setWidth(size); + } else { + } + + } + }); + } + + } + Button btn1 = new SetSizeButton("550px"); + Button btn2 = new SetSizeButton("-1px"); + Button btn3 = new SetSizeButton("75%"); + Button btn4 = new SetSizeButton("100%"); + + layout.addComponent(btn1); + layout.addComponent(btn2); + layout.addComponent(btn3); + layout.addComponent(btn4); + layout.addComponent(c1); + layout.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + layout.addComponent(c2); + btn2.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Label newLabel = new Label("--- NEW LABEL ---"); + newLabel.setSizeUndefined(); + layout.addComponent(newLabel); + } + }); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java new file mode 100644 index 0000000000..7b1c3d9a65 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaption.java @@ -0,0 +1,35 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; + +public class GridCaption extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + layout.addComponent(createLabelsFields(Button.class, true, "")); + layout.addComponent(createLabelsFields(Label.class, true, "")); + layout.addComponent(createLabelsFields(ComboBox.class, true, "")); + layout.addComponent(createLabelsFields(TabSheet.class, false, "")); + super.setup(request); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java new file mode 100644 index 0000000000..ab8046ebf3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridCaptionTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseCaptionTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridCaptionTest extends BaseCaptionTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java new file mode 100644 index 0000000000..bebccfbf9d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizing.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridComponentSizing extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + getLayoutForLayoutSizing("component"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java new file mode 100644 index 0000000000..6572bd2a50 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridComponentSizingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest; + +public class GridComponentSizingTest extends BaseComponentSizingTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java new file mode 100644 index 0000000000..863a4f2c1d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIcon.java @@ -0,0 +1,42 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridIcon extends GridBaseLayoutTestUI { + @Override + protected void setup(VaadinRequest request) { + layout.addComponent(createLabelsFields(TextField.class, true, "")); + layout.addComponent(createLabelsFields(Label.class, true, "")); + layout.addComponent(createLabelsFields(Button.class, true, "")); + layout.addComponent(createLabelsFields(ComboBox.class, true, "")); + layout.addComponent(createLabelsFields(Link.class, true, "")); + layout.addComponent(createLabelsFields(TabSheet.class, true, "")); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java new file mode 100644 index 0000000000..25a0faa88e --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridIconTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseIconTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridIconTest extends BaseIconTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java new file mode 100644 index 0000000000..b3a84cdc26 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpand.java @@ -0,0 +1,64 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutExpand extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + class ExpandButton extends Button { + + public ExpandButton(final int i1, final int i2, final float e1, + final float e2) { + super(); + setCaption("Expand ratio: " + e1 * 100 + " /" + e2 * 100); + addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + layout.setColumnExpandRatio(i1, e1); + layout.setColumnExpandRatio(i2, e2); + } + }); + } + } + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + layout.setColumns(4); + layout.setRows(4); + layout.addComponent(new ExpandButton(1, 2, 1.0f, 0.0f), 0, 0); + layout.addComponent(new ExpandButton(1, 2, 0.5f, 0.50f), 0, 1); + layout.addComponent(new ExpandButton(1, 2, .25f, 0.75f), 0, 2); + + layout.addComponent(t1, 1, 1); + layout.addComponent(t2, 2, 1); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java new file mode 100644 index 0000000000..2a49af52a9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutExpandTest.java @@ -0,0 +1,26 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutExpandTest extends BaseLayoutExpandTest { +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java new file mode 100644 index 0000000000..78a67bdf82 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacing.java @@ -0,0 +1,74 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutMarginSpacing extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + Table t1 = getTestTable(); + Table t2 = getTestTable(); + t1.setSizeFull(); + t2.setSizeFull(); + + final Button btn1 = new Button("Toggle margin on/off"); + btn1.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + boolean margin = layout.getMargin().hasLeft(); + layout.setMargin(!margin); + + } + }); + final Button btn2 = new Button("Toggle spacing on/off"); + btn2.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + layout.setSpacing(!layout.isSpacing()); + } + }); + layout.addComponent(btn1); + layout.addComponent(btn2); + + layout.addComponent(t1); + layout.setMargin(false); + layout.setSpacing(false); + // Must add something around the hr to avoid the margins collapsing + layout.addComponent(new Label( + "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", + ContentMode.HTML)); + layout.addComponent(t2); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..516f3b088b --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutMarginSpacingTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java new file mode 100644 index 0000000000..5b4dd2a947 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java @@ -0,0 +1,54 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TextField; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutRegError extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildLayout(); + super.setup(request); + } + + private void buildLayout() { + + layout.addComponent(createLabelsFields(Label.class, true, "")); + layout.addComponent(createLabelsFields(Button.class, true, "")); + layout.addComponent(createLabelsFields(TabSheet.class, true, "")); + layout.addComponent(createLabelsFields(TextField.class, true, "")); + + layout.addComponent(createLabelsFields(ComboBox.class, true, "")); + layout.addComponent(createLabelsFields(DateField.class, true, "")); + layout.addComponent(createLabelsFields(NativeSelect.class, true, "")); + layout.addComponent(createLabelsFields(CheckBox.class, true, "")); + + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java new file mode 100644 index 0000000000..e377a7b0c4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegErrorTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutRegErrorTest extends BaseLayoutRegErrorTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java new file mode 100644 index 0000000000..8358f91997 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizing.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.server.VaadinRequest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutSizing extends GridBaseLayoutTestUI { + + @Override + protected void setup(VaadinRequest request) { + getLayoutForLayoutSizing("layout"); + super.setup(request); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java new file mode 100644 index 0000000000..c8a48cd70c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutSizingTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.GridLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class GridLayoutSizingTest extends BaseLayoutSizingTest { + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java deleted file mode 100644 index f55867c464..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java +++ /dev/null @@ -1,657 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import java.util.Date; - -import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Resource; -import com.vaadin.server.SystemError; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.UserError; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.AbstractOrderedLayout; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.InlineDateField; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Link; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.Reindeer; - -public class GridLayoutTests extends AbstractLayoutTests { - - private AbstractComponent rc1, col1, col2, col3, row1, row2, row3, x3, x22; - - public GridLayoutTests(LegacyApplication application) { - super(); - } - - @Override - protected Layout getAlignmentTests() { - HorizontalLayout hlo = new HorizontalLayout(); - hlo.setSpacing(true); - GridLayout glo = getTestGrid(); - glo.addStyleName(Reindeer.LAYOUT_WHITE); - Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT, - Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT, - Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER, - Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT, - Alignment.TOP_CENTER, Alignment.TOP_RIGHT }; - - glo.replaceComponent(col1, col1 = new TextField()); - glo.replaceComponent(col2, col2 = new TextField()); - glo.replaceComponent(col3, col3 = new TextField()); - ((TextField) col1).setValue("BOTTOM_RIGHT"); - ((TextField) col2).setValue("BOTTOM_LEFT"); - ((TextField) col3).setValue("BOTTOM_CENTER"); - glo.setComponentAlignment(col2, alignments[0]); - glo.setComponentAlignment(col3, alignments[1]); - glo.setComponentAlignment(col1, alignments[2]); - - glo.setComponentAlignment(row1, alignments[3]); - glo.setComponentAlignment(row2, alignments[4]); - glo.setComponentAlignment(row3, alignments[5]); - hlo.addComponent(glo); - glo = getTestGrid(); - glo.replaceComponent(row1, row1 = new DateField()); - glo.replaceComponent(row2, row2 = new DateField()); - glo.replaceComponent(row3, row3 = new DateField()); - ((DateField) row1).setResolution(DateField.RESOLUTION_SEC); - ((DateField) row2).setResolution(DateField.RESOLUTION_SEC); - ((DateField) row3).setResolution(DateField.RESOLUTION_SEC); - glo.setComponentAlignment(col2, alignments[6]); - glo.setComponentAlignment(col3, alignments[7]); - glo.setComponentAlignment(col1, alignments[8]); - hlo.addComponent(glo); - return hlo; - } - - @Override - protected Layout getCaptionsTests() { - GridLayout glo = getTestGrid(); - glo.setWidth("600px"); - String[] captions = new String[] { - "", - "abcdefghijklmnopq", - "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" }; - glo.replaceComponent(col1, col1 = new TextField()); - glo.replaceComponent(col2, col2 = new TextField()); - glo.replaceComponent(col3, col3 = new TextField()); - - col1.setCaption(captions[0]); - col2.setCaption(captions[1]); - col3.setCaption(captions[2]); - col3.setIcon(new ThemeResource(LOCK_16_PNG)); - - glo.replaceComponent(row1, row1 = new Label()); - glo.replaceComponent(row2, row2 = new Label()); - glo.replaceComponent(row3, row3 = new Label()); - - row1.setCaption(captions[0]); - row2.setCaption(captions[1]); - row3.setCaption(captions[2]); - - glo.replaceComponent(x3, x3 = getTestTabsheet()); - glo.replaceComponent(x22, x22 = getTestTable()); - x22.setComponentError(new UserError("component error, user error")); - - x3.setCaption(captions[1]); - x22.setCaption(captions[2]); - - return glo; - } - - @Override - protected Layout getComponentAddReplaceMoveTests() { - final GridLayout glo = getTestGrid(); - glo.setHeight("350px"); - Layout baseLayout = getBaseLayout(); - final Button button1 = new Button("Test add"); - final Button button2 = new Button("Test replace"); - final Button button3 = new Button("Test move"); - final Button button4 = new Button("Test remove comp 1,1"); - final Button button5 = new Button("Test remove row 0"); - final Button button6 = new Button("Test remove comp row3"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - button5.setId("testButton5"); - button6.setId("testButton6"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(button5); - baseLayout.addComponent(button6); - baseLayout.addComponent(glo); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - button5.setEnabled(false); - button6.setEnabled(false); - - final HorizontalLayout source = new HorizontalLayout(); - source.addComponent(new Label("MOVE LABEL 1")); - source.addComponent(new Label("MOVE LABEL 2")); - - final AbstractComponent cc1 = getTestTabsheet(); - cc1.setCaption("ADDED COMPONENT"); - - final AbstractComponent cc2 = getTestTabsheet(); - cc2.setCaption("REPLACEMENT COMPONENT"); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.addComponent(cc1); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.replaceComponent(x22, cc2); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.moveComponentsFrom(source); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.removeComponent(1, 1); - button4.setEnabled(false); - button5.setEnabled(true); - } - }); - - button5.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.removeRow(0); - button5.setEnabled(false); - button6.setEnabled(true); - } - }); - button6.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.removeComponent(row3); - button6.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getComponentSizingTests() { - final GridLayout glo = getTestGrid(); - glo.setHeight("350px"); - Layout baseLayout = getBaseLayout(); - final Button button1 = new Button("full size, 3x1"); - final Button button2 = new Button("200 px width, 3x1"); - final Button button3 = new Button("200 px width, table"); - final Button button4 = new Button("undefined size+add, table"); - - glo.replaceComponent(x22, x22 = getTestTable()); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(glo); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x3.setSizeFull(); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x3.setWidth("200px"); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x22.setWidth("200px"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - x22.setSizeUndefined(); - ((Table) x22).addItem(new Object[] { "NEW ROW1" }, 3); - ((Table) x22).addItem(new Object[] { "NEW ROW2" }, 4); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getExpandRatiosTests() { - final GridLayout glo = getTestGrid(); - Layout baseLayout = getBaseLayout(); - final Button button1 = new Button("set col 3 expand 1"); - final Button button2 = new Button("set all cols expand 0.25"); - final Button button3 = new Button("set row 0 expand 0.5"); - final Button button4 = new Button("set row 3 expand 0.2"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - glo.setHeight("400px"); - glo.replaceComponent(x22, x22 = getTestTable()); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(glo); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setColumnExpandRatio(3, 1); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setColumnExpandRatio(0, 0.25f); - glo.setColumnExpandRatio(1, 0.25f); - glo.setColumnExpandRatio(2, 0.25f); - glo.setColumnExpandRatio(3, 0.25f); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setRowExpandRatio(0, 0.5f); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setRowExpandRatio(3, 0.3f); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getIconsTests() { - GridLayout glo = getTestGrid(); - glo.setWidth("600px"); - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD")); - glo.replaceComponent(col2, col2 = new Label("LABEL")); - glo.replaceComponent(col3, col3 = new Link("LINK", null)); - - col1.setIcon(icons[0]); - col2.setIcon(icons[1]); - col3.setIcon(icons[0]); - rc1.setIcon(icons[1]); - col3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - col3.setComponentError(new UserError("component error, user error")); - - glo.replaceComponent(row1, row1 = new DateField()); - glo.replaceComponent(row2, row2 = new NativeSelect()); - glo.replaceComponent(row3, row3 = getTestTabsheet()); - - row1.setIcon(icons[1]); - row2.setIcon(icons[0]); - row3.setIcon(icons[1]); - - glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX")); - VerticalLayout pl = new VerticalLayout(); - pl.setMargin(true); - glo.replaceComponent(x22, x22 = new Panel("PANEL", pl)); - x22.setIcon(new ThemeResource(CALENDAR_32_PNG)); - - x3.setIcon(icons[0]); - x22.setIcon(icons[1]); - - return glo; - } - - @Override - protected Layout getLayoutSizingTests() { - final GridLayout glo = getTestGrid(); - Layout baseLayout = getBaseLayout(); - baseLayout.setWidth("500px"); - baseLayout.setHeight("500px"); - final Button button1 = new Button("Set fixed height 350px"); - final Button button2 = new Button( - "Set undefined size and add component"); - final Button button3 = new Button("Set fixed width and height 75%"); - final Button button4 = new Button("Set size full"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - glo.replaceComponent(x22, x22 = getTestTable()); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - baseLayout.addComponent(glo); - // Don't expand the buttons - ((AbstractOrderedLayout) baseLayout).setExpandRatio(glo, 1); - - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setHeight("350px"); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSizeUndefined(); - glo.addComponent(new Label("--- NEW LABEL ---")); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setWidth("75%"); - glo.setHeight("75%"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSizeFull(); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getMarginSpacingTests() { - final GridLayout glo = getTestGrid(); - Layout baseLayout = getBaseLayout(); - baseLayout.setWidth("500px"); - baseLayout.setHeight("500px"); - final Button button1 = new Button("Set margin on"); - final Button button2 = new Button("Set spacing on"); - final Button button3 = new Button("Set margin off"); - final Button button4 = new Button("Set spacing off"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - baseLayout.addComponent(glo); - - // Don't expand the buttons - ((AbstractOrderedLayout) baseLayout).setExpandRatio(glo, 1); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setMargin(true); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSpacing(true); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setMargin(false); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - glo.setSpacing(false); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getRequiredErrorIndicatorsTests() { - GridLayout glo = getTestGrid(); - glo.setWidth("600px"); - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - glo.replaceComponent(col1, col1 = new TextField("TEXTFIELD")); - glo.replaceComponent(col2, col2 = new Label("LABEL")); - // Make sure it doesn't shrink to 0px - col2.setWidth(null); - glo.replaceComponent(col3, col3 = new Link("LINK", null)); - - col1.setIcon(icons[0]); - col1.setComponentError(new UserError("component error, user error")); - col2.setComponentError(new SystemError("component error, system error")); - col3.setComponentError(new UserError("component error, user error")); - - glo.replaceComponent(row1, row1 = new DateField()); - glo.replaceComponent(row2, row2 = new NativeSelect()); - glo.replaceComponent(row3, row3 = getTestTabsheet()); - - ((AbstractField<?>) col1).setRequired(true); - ((AbstractField<?>) col1).setValidationVisible(true); - ((AbstractField<?>) col1).setRequiredError("required error"); - - ((AbstractField<?>) row1).setRequired(true); - ((AbstractField<?>) row1).setValidationVisible(true); - ((AbstractField<?>) row1).setRequiredError("required error"); - - ((AbstractField<?>) row2).setRequired(true); - ((AbstractField<?>) row2).setValidationVisible(true); - ((AbstractField<?>) row2).setRequiredError("required error"); - row2.setComponentError(new UserError("component error, user error")); - - row3.setComponentError(new UserError("component error, user error")); - row3.setIcon(icons[1]); - row3.setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - - glo.replaceComponent(x3, x3 = new CheckBox("CHECKBOX")); - VerticalLayout pl = new VerticalLayout(); - pl.setMargin(true); - glo.replaceComponent(x22, x22 = new Panel("PANEL", pl)); - - x3.setComponentError(new UserError("component error, user error")); - x22.setComponentError(new UserError("component error, user error")); - x22.setIcon(icons[0]); - - return glo; - } - - private GridLayout getTestGrid() { - // Create a 4 by 4 grid layout. - GridLayout grid = new GridLayout(4, 4); - // Fill out the first row using the cursor. - grid.addComponent(rc1 = new Button("R/C 1")); - - grid.addComponent(col1 = new Button("Col " + (grid.getCursorX() + 1))); - grid.addComponent(col2 = new Button("Col " + (grid.getCursorX() + 1))); - grid.addComponent(col3 = new Button("Col " + (grid.getCursorX() + 1))); - - // Fill out the first column using coordinates. - - grid.addComponent(row1 = new Button("Row " + 1), 0, 1); - grid.addComponent(row2 = new Button("Row " + 2), 0, 2); - grid.addComponent(row3 = new Button("Row " + 3), 0, 3); - - // Add some components of various shapes. - grid.addComponent(x3 = new Button("3x1 button"), 1, 1, 3, 1); - grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3); - x22 = new InlineDateField("A 2x2 date field"); - ((InlineDateField) x22).setResolution(DateField.RESOLUTION_DAY); - ((InlineDateField) x22).setValue(new Date(128028960000l)); - grid.addComponent(x22, 2, 2, 3, 3); - grid.setWidth("450px"); - grid.setHeight("450px"); - return grid; - } - - private VerticalLayout getBaseLayout() { - VerticalLayout vlo = new VerticalLayout(); - vlo.setSizeUndefined(); - return vlo; - } - - private AbstractComponent getTestTabsheet() { - TabSheet tabsheet = new TabSheet(); - tabsheet.setSizeUndefined(); - tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource( - GLOBE_16_PNG)); - tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null); - return tabsheet; - } - - private Table getTestTable() { - Table t = new Table(); - t.setSizeUndefined(); - t.setPageLength(5); - t.addContainerProperty("test", String.class, null); - t.addItem(new Object[] { "qwertyuiop asdfghjklzxccvbnm,m,." }, 1); - t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); - return t; - } - -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java new file mode 100644 index 0000000000..1c0e992a86 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMove.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove; +import com.vaadin.ui.HorizontalLayout; + + +public class HAddReplaceMove extends BaseAddReplaceMove { + + /** + * @param layoutClass + */ + public HAddReplaceMove() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java new file mode 100644 index 0000000000..367664069d --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAddReplaceMoveTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest; + +public class HAddReplaceMoveTest extends BaseAddReplaceMoveTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java new file mode 100644 index 0000000000..9864fcaa41 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignment.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignment; +import com.vaadin.ui.HorizontalLayout; + +public class HAlignment extends BaseAlignment { + + public HAlignment() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java new file mode 100644 index 0000000000..055ad8e607 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HAlignmentTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; + +public class HAlignmentTest extends BaseAlignmentTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java new file mode 100644 index 0000000000..bb974a8c68 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaption.java @@ -0,0 +1,32 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseCaption; +import com.vaadin.ui.HorizontalLayout; + + +public class HCaption extends BaseCaption { + + /** + * @param layoutClass + */ + public HCaption() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java new file mode 100644 index 0000000000..c10da9eefe --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HCaptionTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseCaptionTest; + +public class HCaptionTest extends BaseCaptionTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java new file mode 100644 index 0000000000..b042c018eb --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizing.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HComponentSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public HComponentSizing() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java new file mode 100644 index 0000000000..86aa330901 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HComponentSizingTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest; + +public class HComponentSizingTest extends BaseComponentSizingTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.java new file mode 100644 index 0000000000..cb4eb321b9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIcon.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseIcon; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HIcon extends BaseIcon { + + /** + * @param layoutClass + */ + public HIcon() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java new file mode 100644 index 0000000000..e01e1d1726 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HIconTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseIconTest; + +public class HIconTest extends BaseIconTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java new file mode 100644 index 0000000000..273ca07bc4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpand.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpand; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutExpand extends BaseLayoutExpand { + + /** + * @param layoutClass + */ + public HLayoutExpand() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java new file mode 100644 index 0000000000..f24abba9d2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutExpandTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest; + +public class HLayoutExpandTest extends BaseLayoutExpandTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.java new file mode 100644 index 0000000000..9fea380155 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacing.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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutForSpacingMargin; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutMarginSpacing extends BaseLayoutForSpacingMargin { + + /** + * @param layoutClass + */ + public HLayoutMarginSpacing() { + super(HorizontalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..1abae12ce6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutMarginSpacingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest; + +public class HLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java new file mode 100644 index 0000000000..3c7134a061 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegError.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseRegError; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutRegError extends BaseRegError { + + /** + * @param layoutClass + */ + public HLayoutRegError() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java new file mode 100644 index 0000000000..673c08d4fa --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutRegErrorTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; + +public class HLayoutRegErrorTest extends BaseLayoutRegErrorTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java new file mode 100644 index 0000000000..350037b05c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizing.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.HorizontalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class HLayoutSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public HLayoutSizing() { + super(HorizontalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java new file mode 100644 index 0000000000..5f4d52a5d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HLayout/HLayoutSizingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.HLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest; + +public class HLayoutSizingTest extends BaseLayoutSizingTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java deleted file mode 100644 index afa53c012e..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ /dev/null @@ -1,597 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Resource; -import com.vaadin.server.SystemError; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.UserError; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Link; -import com.vaadin.ui.Select; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.Reindeer; - -public class HorizontalLayoutTests extends AbstractLayoutTests { - - public HorizontalLayoutTests(LegacyApplication application) { - super(); - } - - @Override - protected Layout getAlignmentTests() { - Layout baseLayout = getBaseLayout(); - HorizontalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[9]; - String[] styles = { Reindeer.LAYOUT_BLUE, Reindeer.LAYOUT_WHITE }; - Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_LEFT, - Alignment.BOTTOM_CENTER, Alignment.BOTTOM_RIGHT, - Alignment.MIDDLE_LEFT, Alignment.MIDDLE_CENTER, - Alignment.MIDDLE_RIGHT, Alignment.TOP_LEFT, - Alignment.TOP_CENTER, Alignment.TOP_RIGHT }; - - vlo.addStyleName(Reindeer.LAYOUT_WHITE); - baseLayout.addComponent(vlo); - int index = 0; - for (int i = 0; i < components.length; i++) { - if (i > 0 && i % 3 == 0) { - vlo = getTestLaytout(); - vlo.addStyleName(styles[index++]); - baseLayout.addComponent(vlo); - } - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - vlo.addComponent(components[i]); - vlo.setComponentAlignment(components[i], alignments[i]); - } - return baseLayout; - } - - @Override - protected Layout getCaptionsTests() { - Layout baseLayout = getBaseLayout(); - AbstractComponent component = null; - - String[] captions = new String[] { - "", - "abcdefghijklmnopq", - "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" }; - - HorizontalLayout vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new TextField(); - ((TextField) component).setValue("FIELD " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new Label(); - ((Label) component).setValue("Label " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new Select(); - component.setCaption(captions[i]); - component.setIcon(new ThemeResource(LOCK_16_PNG)); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = getTestTabsheet(); - component.setCaption(captions[i]); - component.setComponentError(new UserError("")); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getComponentAddReplaceMoveTests() { - final HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - final HorizontalLayout source = new HorizontalLayout(); - source.addComponent(new Label("OTHER LABEL 1")); - source.addComponent(new Label("OTHER LABEL 2")); - - final AbstractComponent c1 = new Button("BUTTON"); - final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); - final AbstractComponent c3 = new Table("TABLE"); - c3.setHeight("100px"); - c3.setWidth("100%"); - - final Button addButton = new Button("Test add"); - final Button replaceButton = new Button("Test replace"); - final Button moveButton = new Button("Test move"); - final Button removeButton = new Button("Test remove"); - addButton.setId("testButton1"); - replaceButton.setId("testButton2"); - moveButton.setId("testButton3"); - removeButton.setId("testButton4"); - replaceButton.setEnabled(false); - moveButton.setEnabled(false); - removeButton.setEnabled(false); - - addButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.addComponent(new TextField()); - addButton.setEnabled(false); - replaceButton.setEnabled(true); - } - }); - replaceButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.replaceComponent(c1, c3); - replaceButton.setEnabled(false); - moveButton.setEnabled(true); - } - }); - moveButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.moveComponentsFrom(source); - moveButton.setEnabled(false); - removeButton.setEnabled(true); - } - }); - removeButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.removeComponent(c1); - vlo.removeComponent(c2); - removeButton.setEnabled(false); - } - }); - - baseLayout.addComponent(addButton); - baseLayout.addComponent(replaceButton); - baseLayout.addComponent(moveButton); - baseLayout.addComponent(removeButton); - - vlo.addComponent(c1); - vlo.addComponent(c2); - vlo.addComponent(c3); - baseLayout.addComponent(vlo); - - return baseLayout; - } - - @Override - protected Layout getComponentSizingTests() { - final HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - - final AbstractComponent c = getTestTable(); - - final Button biggerButton = new Button("full size"); - final Button smallerButton = new Button("200 px width"); - final Button originalButton = new Button("undefined size+add"); - - biggerButton.setId("testButton1"); - smallerButton.setId("testButton2"); - originalButton.setId("testButton3"); - - baseLayout.addComponent(biggerButton); - baseLayout.addComponent(smallerButton); - baseLayout.addComponent(originalButton); - vlo.addComponent(c); - baseLayout.addComponent(vlo); - - biggerButton.setEnabled(true); - smallerButton.setEnabled(false); - originalButton.setEnabled(false); - - biggerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setSizeFull(); - biggerButton.setEnabled(false); - smallerButton.setEnabled(true); - } - }); - smallerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setWidth("200px"); - smallerButton.setEnabled(false); - originalButton.setEnabled(true); - } - }); - originalButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - originalButton.setEnabled(false); - c.setSizeUndefined(); - ((Table) c) - .addItem( - new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" }, - 3); - } - }); - - return baseLayout; - } - - @Override - protected Layout getLayoutSizingTests() { - final HorizontalLayout vlo = getTestLaytout(); - vlo.setSpacing(false); - vlo.setMargin(false); - Layout baseLayout = getBaseLayout(); - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set fixed height 350px"); - final Button button2 = new Button( - "Set undefined size and add component"); - final Button button3 = new Button("Set fixed width and height 75%"); - final Button button4 = new Button("Set size full"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - vlo.addComponent(c1); - vlo.addComponent(c2); - vlo.setExpandRatio(c1, 0.5f); - vlo.setExpandRatio(c2, 0.5f); - - baseLayout.addComponent(vlo); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setHeight("350px"); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSizeUndefined(); - Label label = new Label("--- NEW LABEL ---"); - label.setWidth(null); - vlo.addComponent(label); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setWidth("75%"); - vlo.setHeight("75%"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSizeFull(); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getExpandRatiosTests() { - final HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Expand to 1/undefined"); - final Button button2 = new Button("Expand to 0.5/0.5"); - final Button button3 = new Button("Expand to 0.75/0.25"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - - vlo.addComponent(c1); - vlo.addComponent(c2); - baseLayout.addComponent(vlo); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setExpandRatio(c1, 1.0f); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setExpandRatio(c1, 0.5f); - vlo.setExpandRatio(c2, 0.5f); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setExpandRatio(c1, 0.75f); - vlo.setExpandRatio(c2, 0.25f); - button3.setEnabled(false); - } - }); - return baseLayout; - } - - @Override - protected Layout getIconsTests() { - HorizontalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[2]; - Layout baseLayout = getBaseLayout(); - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - for (int i = 0; i < components.length; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - components[i].setIcon(icons[i]); - components[i] - .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - vlo.addComponent(components[i]); - } - for (int i = 0; i < components.length; i++) { - components[i] = new Label(); - ((Label) components[i]).setValue("Label " + i); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < components.length; i++) { - components[i] = new Select(); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - for (int i = 0; i < components.length; i++) { - components[i] = new Button(); - components[i].setComponentError(new UserError( - "component error, user error")); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - for (int i = 0; i < components.length; i++) { - components[i] = new Link("Link", null); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getMarginSpacingTests() { - final HorizontalLayout vlo = getTestLaytout(); - vlo.setSpacing(false); - vlo.setMargin(false); - Layout baseLayout = getBaseLayout(); - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set margin on"); - final Button button2 = new Button("Set spacing on"); - final Button button3 = new Button("Set margin off"); - final Button button4 = new Button("Set spacing off"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - baseLayout.addComponent(button1); - baseLayout.addComponent(button2); - baseLayout.addComponent(button3); - baseLayout.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - vlo.addComponent(c1); - vlo.addComponent(c2); - vlo.setExpandRatio(c1, 0.5f); - vlo.setExpandRatio(c2, 0.5f); - baseLayout.addComponent(vlo); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setMargin(true); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSpacing(true); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setMargin(false); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo.setSpacing(false); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getRequiredErrorIndicatorsTests() { - HorizontalLayout vlo = getTestLaytout(); - Layout baseLayout = getBaseLayout(); - AbstractComponent[] components = new AbstractComponent[4]; - components[0] = new Label("LABEL"); - components[0].setSizeUndefined(); - components[1] = new Button("BUTTON"); - components[2] = getTestTable(); - components[3] = getTestTabsheet(); - components[3].setIcon(new ThemeResource(LOCK_16_PNG)); - - AbstractField<?>[] fields = new AbstractField<?>[5]; - fields[0] = new TextField(); - fields[0].setRequired(true); - fields[0].setValidationVisible(true); - fields[0].setRequiredError("required error"); - - fields[1] = new TextField(); - ((TextField) fields[1]).setValue("TEXTFIELD2"); - fields[1] - .setComponentError(new UserError("component error, user error")); - - fields[2] = new Select(); - fields[2].setComponentError(new SystemError( - "component error, system error")); - fields[3] = new DateField(); - fields[3].setComponentError(new SystemError( - "component error, system error")); - - fields[4] = new CheckBox(); - fields[4] - .setComponentError(new UserError("component error, user error")); - - for (int i = 0; i < components.length; i++) { - components[i].setComponentError(new UserError( - "component error, user error")); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < fields.length; i++) { - vlo.addComponent(fields[i]); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - private VerticalLayout getBaseLayout() { - VerticalLayout vlo = new VerticalLayout(); - vlo.setSizeUndefined(); - return vlo; - } - - private HorizontalLayout getTestLaytout() { - HorizontalLayout vlo = new HorizontalLayout(); - vlo.setHeight("100px"); - vlo.setWidth("750px"); - return vlo; - } - - private AbstractComponent getTestTabsheet() { - TabSheet tabsheet = new TabSheet(); - tabsheet.setSizeUndefined(); - tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource( - GLOBE_16_PNG)); - tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null); - return tabsheet; - } - - private Table getTestTable() { - Table t = new Table(); - t.setSizeUndefined(); - t.setPageLength(5); - t.addContainerProperty("test", String.class, null); - t.addItem(new Object[] { "qwertyuiop asdfghjkl zxccvbnm,m,." }, 1); - t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); - return t; - } -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java deleted file mode 100644 index 5b68e04144..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import java.lang.reflect.Method; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Layout; -import com.vaadin.ui.LegacyWindow; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.Reindeer; - -@SuppressWarnings("serial") -public class LayoutTesterApplication extends AbstractTestCase { - Button nextButton = new Button("Next"); - private int layoutIndex = -1; - - static final String[] layoutGetters = new String[] { "getCaptionsTests", - "getIconsTests", "getRequiredErrorIndicatorsTests", - "getAlignmentTests", "getExpandRatiosTests", - "getMarginSpacingTests", "getComponentAddReplaceMoveTests", - "getComponentSizingTests", "getLayoutSizingTests" }; - public static final String NEXT_BUTTON_ID = "nextButton"; - private static final String LAYOUT_SELECT_ID = "layoutSelect"; - - private LegacyWindow mainWindow; - private NativeSelect layoutSelector; - - @Override - public void init() { - nextButton.setId(NEXT_BUTTON_ID); - mainWindow = new LegacyWindow("LayoutTesterApplication"); - setMainWindow(mainWindow); - nextLayout(); - - nextButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = -1577298910202253538L; - - @Override - public void buttonClick(ClickEvent event) { - nextLayout(); - } - }); - } - - private void nextLayout() { - try { - mainWindow.removeAllComponents(); - HorizontalLayout vlo = new HorizontalLayout(); - vlo.setSpacing(true); - ++layoutIndex; - if (layoutIndex >= layoutGetters.length) { - layoutIndex = 0; - } - mainWindow.addComponent(vlo); - vlo.addComponent(nextButton); - vlo.addComponent(getLayoutTypeSelect()); - vlo.addComponent(new UndefWideLabel(getLayoutGetterMethod( - layoutGetters[layoutIndex]).getName())); - - Layout lo = null; - if (layoutSelector.getValue() == VerticalLayout.class) { - lo = getVerticalTestLayout(layoutIndex); - } else if (layoutSelector.getValue() == HorizontalLayout.class) { - lo = getHorizontalTestLayout(layoutIndex); - } else if (layoutSelector.getValue() == GridLayout.class) { - lo = getGridTestLayout(layoutIndex); - } - if (lo != null) { - lo.addStyleName(Reindeer.LAYOUT_BLUE); - mainWindow.addComponent(lo); - } - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - private Method getLayoutGetterMethod(String method) { - try { - return AbstractLayoutTests.class.getDeclaredMethod(method); - } catch (SecurityException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - public Layout getVerticalTestLayout(int index) throws Exception { - VerticalLayoutTests vlotest = new VerticalLayoutTests(this); - return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke( - vlotest, (Object[]) null); - } - - public Layout getHorizontalTestLayout(int index) throws Exception { - HorizontalLayoutTests hlotest = new HorizontalLayoutTests(this); - return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke( - hlotest, (Object[]) null); - } - - public Layout getGridTestLayout(int index) throws Exception { - GridLayoutTests hlotest = new GridLayoutTests(this); - return (Layout) getLayoutGetterMethod(layoutGetters[index]).invoke( - hlotest, (Object[]) null); - } - - private NativeSelect getLayoutTypeSelect() { - if (layoutSelector == null) { - layoutSelector = new NativeSelect(); - layoutSelector.setId(LAYOUT_SELECT_ID); - layoutSelector.addItem(VerticalLayout.class); - layoutSelector.addItem(HorizontalLayout.class); - layoutSelector.addItem(GridLayout.class); - layoutSelector.setNullSelectionAllowed(false); - layoutSelector.setImmediate(true); - layoutSelector.select(VerticalLayout.class); - layoutSelector.addListener(new Property.ValueChangeListener() { - private static final long serialVersionUID = -605319614765838359L; - - @Override - public void valueChange(ValueChangeEvent event) { - layoutIndex = -1; - nextLayout(); - } - }); - } - return layoutSelector; - } - - @Override - protected String getDescription() { - return "Test application for VerticalLayout, HorizontalLayout, and GridLayout"; - } - - @Override - protected Integer getTicketNumber() { - return 5334; - } - -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java deleted file mode 100644 index 5d8a6e0e7a..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.layouts.layouttester; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.Select; - -import com.vaadin.tests.tb3.MultiBrowserTest; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.VerticalLayout; - -public class LayoutTesterApplicationTest extends MultiBrowserTest { - - @Override - protected DesiredCapabilities getDesiredCapabilities() { - DesiredCapabilities cap = new DesiredCapabilities( - super.getDesiredCapabilities()); - cap.setCapability("nativeEvents", false); - - return cap; - } - - Map<String, Integer> numberOfSubTests = new HashMap<String, Integer>(); - private Set<String> tableOrIconsTests = new HashSet<String>(); - - { - numberOfSubTests.put("getExpandRatiosTests", 3); - numberOfSubTests.put("getLayoutSizingTests", 4); - numberOfSubTests.put("getComponentAddReplaceMoveTests", 4); - numberOfSubTests.put("getMarginSpacingTests", 4); - numberOfSubTests.put("getComponentSizingTests", 3); - - tableOrIconsTests.add("getComponentSizingTests"); - tableOrIconsTests.add("getExpandRatiosTests"); - tableOrIconsTests.add("getLayoutSizingTests"); - tableOrIconsTests.add("getMarginSpacingTests"); - tableOrIconsTests.add("getIconsTests"); - - } - - @Test - public void verticalLayout() throws Exception { - openTestURL(); - runTest(VerticalLayout.class); - } - - @Test - public void horizontalLayout() throws Exception { - openTestURL(); - runTest(HorizontalLayout.class); - } - - @Test - public void gridLayout() throws Exception { - numberOfSubTests.put("getComponentAddReplaceMoveTests", 6); - numberOfSubTests.put("getComponentSizingTests", 4); - numberOfSubTests.put("getExpandRatiosTests", 4); - - openTestURL(); - runTest(GridLayout.class); - } - - private void runTest(Class<?> layoutClass) throws Exception { - new Select(vaadinElementById("layoutSelect").findElement( - By.xpath("select"))) - .selectByVisibleText(layoutClass.toString()); - - for (String subTest : LayoutTesterApplication.layoutGetters) { - compareScreen(subTest); - Integer subTests = numberOfSubTests.get(subTest); - if (subTests != null) { - for (int i = 1; i <= subTests; i++) { - clickAndCompareScreen(subTest, "testButton" + i); - } - } - - hitButton("nextButton"); - } - - } - - /** - * Clicks the button with the given id and compares the result to a - * screenshot named 'screenshotPrefix'-buttonCaption. - * - * @param screenshotPrefix - * @param buttonId - * @throws Exception - */ - private void clickAndCompareScreen(String screenshotPrefix, String buttonId) - throws Exception { - hitButton(buttonId); - - if (needsDelayToStabilize(screenshotPrefix)) { - // Table does some extra layout phase and TestBench does not always - // take this into account, grabbing screenshots before the layout - // phase is done (see #12866). - sleep(500); - } - compareScreen(screenshotPrefix + "-" - + sanitize(driver.findElement(By.id(buttonId)).getText())); - } - - private boolean needsDelayToStabilize(String screenshotPrefix) { - return tableOrIconsTests.contains(screenshotPrefix); - } - - private String sanitize(String text) { - return text.replace("%", "pct").replaceAll("[^a-zA-Z0-9]", "-"); - } -} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java new file mode 100644 index 0000000000..a0ef960f57 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMove.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VAddReplaceMove extends BaseAddReplaceMove { + + /** + * @param layoutClass + */ + public VAddReplaceMove() { + super(VerticalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java new file mode 100644 index 0000000000..70f7237c96 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAddReplaceMoveTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMoveTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VAddReplaceMoveTest extends BaseAddReplaceMoveTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java new file mode 100644 index 0000000000..9872b4bfd7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignment.java @@ -0,0 +1,25 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignment; +import com.vaadin.ui.VerticalLayout; + +public class VAlignment extends BaseAlignment { + public VAlignment() { + super(VerticalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java new file mode 100644 index 0000000000..f49787754c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VAlignmentTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseAlignmentTest; + +public class VAlignmentTest extends BaseAlignmentTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java new file mode 100644 index 0000000000..b2f50961cb --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaption.java @@ -0,0 +1,38 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseCaption; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VCaption extends BaseCaption { + + /** + * @param layoutClass + */ + public VCaption() { + super(VerticalLayout.class); + // TODO Auto-generated constructor stub + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java new file mode 100644 index 0000000000..942736b286 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VCaptionTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseCaptionTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VCaptionTest extends BaseCaptionTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.java new file mode 100644 index 0000000000..67fcb85652 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizing.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VComponentSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public VComponentSizing() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java new file mode 100644 index 0000000000..bef10a6a58 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest; + +public class VComponentSizingTest extends BaseComponentSizingTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.java new file mode 100644 index 0000000000..1420be4907 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIcon.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseIcon; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VIcon extends BaseIcon { + + /** + * @param layoutClass + */ + public VIcon() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java new file mode 100644 index 0000000000..221bf2e2db --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VIconTest.java @@ -0,0 +1,21 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseIconTest; + +public class VIconTest extends BaseIconTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.java new file mode 100644 index 0000000000..15a31b16f0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpand.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpand; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutExpand extends BaseLayoutExpand { + + /** + * @param layoutClass + */ + public VLayoutExpand() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java new file mode 100644 index 0000000000..57bb134be7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutExpandTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutExpandTest; + + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VLayoutExpandTest extends BaseLayoutExpandTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.java new file mode 100644 index 0000000000..d6d9040bae --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacing.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseLayoutForSpacingMargin; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutMarginSpacing extends BaseLayoutForSpacingMargin { + + /** + * @param layoutClass + */ + public VLayoutMarginSpacing() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java new file mode 100644 index 0000000000..89ffdf792f --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutMarginSpacingTest.java @@ -0,0 +1,22 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutMarginSpacingTest; + +public class VLayoutMarginSpacingTest extends BaseLayoutMarginSpacingTest { + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java new file mode 100644 index 0000000000..72fd35b842 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegError.java @@ -0,0 +1,36 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseRegError; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutRegError extends BaseRegError { + + /** + * @param layoutClass + */ + public VLayoutRegError() { + super(VerticalLayout.class); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java new file mode 100644 index 0000000000..e3e5914e3a --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutRegErrorTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutRegErrorTest; + + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VLayoutRegErrorTest extends BaseLayoutRegErrorTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.java new file mode 100644 index 0000000000..ea6464cfb7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizing.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.layouts.layouttester.VLayout; + +import com.vaadin.annotations.Theme; +import com.vaadin.tests.layouts.layouttester.BaseComponentSizing; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ + +public class VLayoutSizing extends BaseComponentSizing { + + /** + * @param layoutClass + */ + public VLayoutSizing() { + super(VerticalLayout.class); + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java new file mode 100644 index 0000000000..372eb9cba4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VLayout/VLayoutSizingTest.java @@ -0,0 +1,27 @@ +/* + * 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.layouts.layouttester.VLayout; + +import com.vaadin.tests.layouts.layouttester.BaseLayoutSizingTest; + + +/** + * + * @since + * @author Vaadin Ltd + */ +public class VLayoutSizingTest extends BaseLayoutSizingTest { +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java deleted file mode 100644 index df9be8ffd0..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ /dev/null @@ -1,634 +0,0 @@ -package com.vaadin.tests.layouts.layouttester; - -import com.vaadin.server.LegacyApplication; -import com.vaadin.server.Resource; -import com.vaadin.server.SystemError; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.UserError; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; -import com.vaadin.ui.Link; -import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Select; -import com.vaadin.ui.TabSheet; -import com.vaadin.ui.Table; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; - -public class VerticalLayoutTests extends AbstractLayoutTests { - - public VerticalLayoutTests(LegacyApplication application) { - super(); - } - - @Override - protected Layout getAlignmentTests() { - Layout baseLayout = getBaseLayout(); - ((HorizontalLayout) baseLayout).setSpacing(true); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[9]; - Alignment[] alignments = new Alignment[] { Alignment.BOTTOM_CENTER, - Alignment.BOTTOM_LEFT, Alignment.BOTTOM_RIGHT, - Alignment.MIDDLE_CENTER, Alignment.MIDDLE_LEFT, - Alignment.MIDDLE_RIGHT, Alignment.TOP_CENTER, - Alignment.TOP_LEFT, Alignment.TOP_RIGHT }; - - for (int i = 0; i < components.length / 2; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - vlo.addComponent(components[i]); - vlo.setComponentAlignment(components[i], alignments[i]); - vlo.addComponent(new Label("<hr />", ContentMode.HTML)); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = components.length / 2; i < components.length; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - vlo.addComponent(components[i]); - vlo.setComponentAlignment(components[i], alignments[i]); - vlo.addComponent(new Label("<hr />", ContentMode.HTML)); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getCaptionsTests() { - Layout baseLayout = getBaseLayout(); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent component = null; - - String[] captions = new String[] { - "", - "abcdefghijklmnopq", - "abc def hij klm nop qrs tuv xyz qaz wsx edc rfv tgb yhn ujm mko nji bhu vgy cft cde" }; - - for (int i = 0; i < captions.length; i++) { - component = new TextField(); - ((TextField) component).setValue("FIELD " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - for (int i = 0; i < captions.length; i++) { - component = new Label(); - ((Label) component).setValue("Label " + i); - component.setCaption(captions[i]); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - vlo = getTestLaytout(); - for (int i = 0; i < captions.length; i++) { - component = new Select(); - component.setCaption(captions[i]); - component.setIcon(new ThemeResource(LOCK_16_PNG)); - vlo.addComponent(component); - } - for (int i = 0; i < captions.length; i++) { - component = getTestTabsheet(); - component.setCaption(captions[i]); - component.setComponentError(new UserError("")); - vlo.addComponent(component); - } - baseLayout.addComponent(vlo); - return baseLayout; - } - - @Override - protected Layout getComponentAddReplaceMoveTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - final VerticalLayout vlo2 = getTestLaytout(); - - // Set undefined height to avoid expanding - vlo2.setHeight(null); - - final HorizontalLayout source = new HorizontalLayout(); - source.addComponent(new Label("OTHER LABEL 1")); - source.addComponent(new Label("OTHER LABEL 2")); - - final AbstractComponent c1 = new Button("BUTTON"); - final AbstractComponent c2 = new Label("<b>LABEL</b>", ContentMode.HTML); - final AbstractComponent c3 = new Table("TABLE"); - c3.setHeight("100px"); - c3.setWidth("100%"); - - final Button addButton = new Button("Test add"); - final Button replaceButton = new Button("Test replace"); - final Button moveButton = new Button("Test move"); - final Button removeButton = new Button("Test remove"); - addButton.setId("testButton1"); - replaceButton.setId("testButton2"); - moveButton.setId("testButton3"); - removeButton.setId("testButton4"); - - replaceButton.setEnabled(false); - moveButton.setEnabled(false); - removeButton.setEnabled(false); - - addButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.addComponent(new TextField()); - addButton.setEnabled(false); - replaceButton.setEnabled(true); - } - }); - replaceButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.replaceComponent(c1, c3); - replaceButton.setEnabled(false); - moveButton.setEnabled(true); - } - }); - moveButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.moveComponentsFrom(source); - moveButton.setEnabled(false); - removeButton.setEnabled(true); - } - }); - removeButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.removeComponent(c1); - vlo2.removeComponent(c2); - removeButton.setEnabled(false); - } - }); - - vlo.addComponent(addButton); - vlo.addComponent(replaceButton); - vlo.addComponent(moveButton); - vlo.addComponent(removeButton); - - baseLayout.addComponent(vlo); - vlo2.addComponent(c1); - vlo2.addComponent(c2); - vlo2.addComponent(c3); - baseLayout.addComponent(vlo2); - return baseLayout; - } - - @Override - protected Layout getComponentSizingTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - - final AbstractComponent c = getTestTable(); - - final Button biggerButton = new Button("full size"); - final Button smallerButton = new Button("200 px width"); - final Button originalButton = new Button("undefined size and add"); - biggerButton.setId("testButton1"); - smallerButton.setId("testButton2"); - originalButton.setId("testButton3"); - vlo.addComponent(biggerButton); - vlo.addComponent(smallerButton); - vlo.addComponent(originalButton); - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - vlo2.addComponent(c); - baseLayout.addComponent(vlo2); - - biggerButton.setEnabled(true); - smallerButton.setEnabled(false); - originalButton.setEnabled(false); - - biggerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setSizeFull(); - biggerButton.setEnabled(false); - smallerButton.setEnabled(true); - } - }); - smallerButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - c.setWidth("200px"); - smallerButton.setEnabled(false); - originalButton.setEnabled(true); - } - }); - originalButton.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - originalButton.setEnabled(false); - c.setSizeUndefined(); - ((Table) c) - .addItem( - new Object[] { "VYVTCTC VYVYV ECECCE NIDSD SDMPOM" }, - 3); - } - }); - - return baseLayout; - } - - @Override - protected Layout getLayoutSizingTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - - vlo.setSpacing(false); - vlo.setMargin(false); - - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set fixed height 350px"); - final Button button2 = new Button( - "Set undefined size and add component"); - final Button button3 = new Button("Set fixed width and height 75%"); - final Button button4 = new Button("Set size full"); - - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - vlo.addComponent(button1); - vlo.addComponent(button2); - vlo.addComponent(button3); - vlo.addComponent(button4); - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - vlo2.addComponent(c1); - vlo2.addComponent(new Label( - "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", - ContentMode.HTML)); - vlo2.addComponent(c2); - vlo2.setExpandRatio(c1, 0.5f); - vlo2.setExpandRatio(c2, 0.5f); - baseLayout.addComponent(vlo2); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setHeight("350px"); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSizeUndefined(); - Label newLabel = new Label("--- NEW LABEL ---"); - newLabel.setSizeUndefined(); - vlo2.addComponent(newLabel); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setWidth("75%"); - vlo2.setHeight("75%"); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSizeFull(); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getExpandRatiosTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Expand to 1/undefined"); - button1.setId("testButton1"); - final Button button2 = new Button("Expand to 0.5/0.5"); - button2.setId("testButton2"); - final Button button3 = new Button("Expand to 0.75/0.25"); - button3.setId("testButton3"); - - vlo.addComponent(button1); - vlo.addComponent(button2); - vlo.addComponent(button3); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - - vlo2.addComponent(c1); - vlo2.addComponent(c2); - baseLayout.addComponent(vlo2); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setExpandRatio(c1, 1.0f); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setExpandRatio(c1, 0.5f); - vlo2.setExpandRatio(c2, 0.5f); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setExpandRatio(c1, 0.75f); - vlo2.setExpandRatio(c2, 0.25f); - button3.setEnabled(false); - } - }); - return baseLayout; - } - - @Override - protected Layout getIconsTests() { - Layout baseLayout = getBaseLayout(); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[2]; - - Resource[] icons = new Resource[] { new ThemeResource(CALENDAR_32_PNG), - new ThemeResource(LOCK_16_PNG) }; - - for (int i = 0; i < components.length; i++) { - components[i] = new TextField(); - ((TextField) components[i]).setValue("FIELD " + i); - components[i].setIcon(icons[i]); - components[i] - .setCaption("long test caption bewucbwuebco or bmort b cbwecubw wbeucwe asdasd asdasda asdasd"); - vlo.addComponent(components[i]); - } - - for (int i = 0; i < components.length; i++) { - components[i] = new Label(); - ((Label) components[i]).setValue("Label " + i); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - - for (int i = 0; i < components.length; i++) { - components[i] = new Select(); - components[i].setIcon(icons[i]); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - for (int i = 0; i < components.length; i++) { - components[i] = new Button(); - components[i].setComponentError(new UserError( - "component error, user error")); - components[i].setIcon(icons[i]); - vlo2.addComponent(components[i]); - } - - for (int i = 0; i < components.length; i++) { - components[i] = new Link("Link", null); - components[i].setIcon(icons[i]); - vlo2.addComponent(components[i]); - } - baseLayout.addComponent(vlo2); - return baseLayout; - } - - @Override - protected Layout getMarginSpacingTests() { - Layout baseLayout = getBaseLayout(); - final VerticalLayout vlo = getTestLaytout(); - vlo.setSpacing(false); - vlo.setMargin(false); - - final AbstractComponent c1 = getTestTable(); - c1.setSizeFull(); - final AbstractComponent c2 = getTestTable(); - c2.setSizeFull(); - - final Button button1 = new Button("Set margin on"); - final Button button2 = new Button("Set spacing on"); - final Button button3 = new Button("Set margin off"); - final Button button4 = new Button("Set spacing off"); - button1.setId("testButton1"); - button2.setId("testButton2"); - button3.setId("testButton3"); - button4.setId("testButton4"); - - vlo.addComponent(button1); - vlo.addComponent(button2); - vlo.addComponent(button3); - vlo.addComponent(button4); - button1.setEnabled(true); - button2.setEnabled(false); - button3.setEnabled(false); - button4.setEnabled(false); - - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - - vlo2.addComponent(c1); - // Must add something around the hr to avoid the margins collapsing - vlo2.addComponent(new Label( - "<div style='height: 1px'></div><hr /><div style='height: 1px'></div>", - ContentMode.HTML)); - vlo2.addComponent(c2); - vlo2.setExpandRatio(c1, 0.5f); - vlo2.setExpandRatio(c2, 0.5f); - baseLayout.addComponent(vlo2); - - button1.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setMargin(true); - button1.setEnabled(false); - button2.setEnabled(true); - } - }); - button2.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSpacing(true); - button2.setEnabled(false); - button3.setEnabled(true); - } - }); - button3.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setMargin(false); - button3.setEnabled(false); - button4.setEnabled(true); - } - }); - button4.addListener(new Button.ClickListener() { - private static final long serialVersionUID = 7716267156088629379L; - - @Override - public void buttonClick(ClickEvent event) { - vlo2.setSpacing(false); - button4.setEnabled(false); - } - }); - - return baseLayout; - } - - @Override - protected Layout getRequiredErrorIndicatorsTests() { - Layout baseLayout = getBaseLayout(); - VerticalLayout vlo = getTestLaytout(); - AbstractComponent[] components = new AbstractComponent[4]; - components[0] = new Label("LABEL"); - components[0].setSizeUndefined(); - components[1] = new Button("BUTTON"); - components[2] = getTestTable(); - components[3] = getTestTabsheet(); - components[3].setIcon(new ThemeResource(LOCK_16_PNG)); - - AbstractField<?>[] fields = new AbstractField<?>[6]; - fields[0] = new TextField(); - fields[0].setRequired(true); - fields[0].setValidationVisible(true); - fields[0].setRequiredError("required error"); - - fields[1] = new TextField(); - ((TextField) fields[1]).setValue("TEXTFIELD2"); - fields[1] - .setComponentError(new UserError("component error, user error")); - - fields[2] = new Select(); - fields[2].setComponentError(new SystemError( - "component error, system error")); - fields[3] = new DateField(); - fields[3].setComponentError(new SystemError( - "component error, system error")); - - fields[4] = new CheckBox(); - fields[4] - .setComponentError(new UserError("component error, user error")); - - fields[5] = new NativeSelect(); - fields[5].setRequired(true); - fields[5].setValidationVisible(true); - fields[5].setRequiredError("required error"); - fields[5] - .setComponentError(new UserError("component error, user error")); - fields[5].setIcon(new ThemeResource(CALENDAR_32_PNG)); - - for (int i = 0; i < components.length; i++) { - components[i].setComponentError(new UserError( - "component error, user error")); - vlo.addComponent(components[i]); - } - baseLayout.addComponent(vlo); - final VerticalLayout vlo2 = getTestLaytout(); - for (int i = 0; i < fields.length; i++) { - vlo2.addComponent(fields[i]); - } - - baseLayout.addComponent(vlo2); - return baseLayout; - } - - private HorizontalLayout getBaseLayout() { - HorizontalLayout hlo = new HorizontalLayout(); - hlo.setSizeUndefined(); - return hlo; - } - - private VerticalLayout getTestLaytout() { - VerticalLayout vlo = new VerticalLayout(); - vlo.setHeight("500px"); - vlo.setWidth("400px"); - return vlo; - } - - private AbstractComponent getTestTabsheet() { - TabSheet tabsheet = new TabSheet(); - tabsheet.setSizeUndefined(); - tabsheet.addTab(new UndefWideLabel("TAB1"), "TAB1", new ThemeResource( - GLOBE_16_PNG)); - tabsheet.addTab(new UndefWideLabel("TAB2"), "TAB2", null); - return tabsheet; - } - - private Table getTestTable() { - Table t = new Table(); - t.setSizeUndefined(); - t.setPageLength(5); - t.addContainerProperty("test", String.class, null); - t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1); - t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2); - return t; - } -} diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 3745d60fd8..8783a4dc42 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -24,6 +24,7 @@ import java.net.URL; import java.util.Collections; import java.util.List; +import com.vaadin.testbench.TestBenchElement; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; @@ -35,6 +36,8 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.HasInputDevices; import org.openqa.selenium.interactions.Keyboard; import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; @@ -51,6 +54,8 @@ import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.ui.UI; +import static com.vaadin.tests.tb3.TB3Runner.localWebDriverIsUsed; + /** * Base class for TestBench 3+ tests. All TB3+ tests in the project should * extend this class. @@ -126,7 +131,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } else { capabilities = getDesiredCapabilities(); - if (System.getProperty("useLocalWebDriver") != null) { + if (localWebDriverIsUsed()) { setupLocalDriver(capabilities); } else { WebDriver dr = TestBench.createDriver(new RemoteWebDriver( @@ -151,6 +156,14 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } + protected WebElement getTooltipElement() { + return getDriver().findElement(com.vaadin.testbench.By.className("v-tooltip-text")); + } + + protected Coordinates getCoordinates(TestBenchElement element) { + return ((Locatable) element.getWrappedElement()).getCoordinates(); + } + @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface RunLocally { diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java index 74073af217..ccbb6ca872 100644 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -40,6 +40,16 @@ import org.openqa.selenium.remote.DesiredCapabilities; */ public abstract class MultiBrowserTest extends PrivateTB3Configuration { + protected List<DesiredCapabilities> getBrowsersExcludingIE() { + List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers()); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + browsers.remove(Browser.IE9.getDesiredCapabilities()); + browsers.remove(Browser.IE10.getDesiredCapabilities()); + browsers.remove(Browser.IE11.getDesiredCapabilities()); + + return browsers; + } + public enum Browser { FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI( BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java index 69880008ff..4d29e479e2 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java @@ -61,7 +61,7 @@ public class TB3Runner extends BlockJUnit4ClassRunner { private static final ExecutorService service; static { - if (System.getProperty("useLocalWebDriver") != null) { + if (localWebDriverIsUsed()) { MAX_CONCURRENT_TESTS = 10; } else { MAX_CONCURRENT_TESTS = 50; @@ -69,6 +69,12 @@ public class TB3Runner extends BlockJUnit4ClassRunner { service = Executors.newFixedThreadPool(MAX_CONCURRENT_TESTS); } + protected static boolean localWebDriverIsUsed() { + String useLocalWebDriver = System.getProperty("useLocalWebDriver"); + + return useLocalWebDriver != null && useLocalWebDriver.toLowerCase().equals("true"); + } + public TB3Runner(Class<?> klass) throws InitializationError { super(klass); setScheduler(new ParallelScheduler(service)); diff --git a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java new file mode 100644 index 0000000000..86ac8c1f12 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.tb3; + +import java.util.NoSuchElementException; + +import org.junit.Assert; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; + +/** + * Base class for TestBench 3+ tests that use tooltips. This class contains + * utility methods for testing tooltip use. + * + * @author Vaadin Ltd + */ +public abstract class TooltipTest extends MultiBrowserTest { + + protected void clearTooltip() throws Exception { + moveToRoot(); + Thread.sleep(500); + checkTooltipNotPresent(); + } + + protected void checkTooltip(String locator, String value) throws Exception { + checkTooltip(By.vaadin(locator), value); + } + + protected void checkTooltip(org.openqa.selenium.By by, String value) + throws Exception { + checkTooltip(getDriver().findElement(by), value); + } + + protected void checkTooltip(WebElement element, String value) + throws Exception { + testBenchElement(element).showTooltip(); + if (null != value) { + checkTooltip(value); + } else { + checkTooltipNotPresent(); + } + } + + protected void checkTooltip(String value) throws Exception { + WebElement tooltip = getTooltip(); + Assert.assertEquals(value, tooltip.getText()); + Assert.assertTrue("Tooltip should be in viewport", tooltip + .getLocation().getX() >= 0); + } + + protected void moveToRoot() { + WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); + moveMouseToTopLeft(uiRoot); + } + + protected WebElement getTooltip() throws InterruptedException { + org.openqa.selenium.By tooltipBy = By.vaadin("Root/VTooltip[0]"); + return getDriver().findElement(tooltipBy); + } + + protected void checkTooltipNotPresent() throws Exception { + try { + WebElement tooltip = getTooltip(); + if (!"".equals(tooltip.getText()) + || tooltip.getLocation().getX() > -999) { + Assert.fail("Found tooltip that shouldn't be visible: " + + tooltip.getText() + " at " + tooltip.getLocation()); + } + } catch (NoSuchElementException e) { + Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools"); + } + } + + protected void moveMouseToTopLeft(WebElement element) { + new Actions(getDriver()).moveToElement(element, 0, 0).perform(); + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java new file mode 100644 index 0000000000..5c7b52d96f --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.VerticalLayout; + +public class StationaryTooltip extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout vl = new VerticalLayout(); + Button button = new Button("Button"); + button.setDescription("description"); + + button.setWidth("200px"); + vl.addComponent(button); + + addComponent(vl); + } + + @Override + protected String getTestDescription() { + return null; + } + + @Override + protected Integer getTicketNumber() { + return null; + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java new file mode 100644 index 0000000000..6b751e7a6b --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java @@ -0,0 +1,77 @@ +package com.vaadin.tests.tooltip; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class StationaryTooltipTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // With IEDriver, the cursor seems to jump to default position after the + // mouse move, + // so we are not able to test the tooltip behaviour properly. + return getBrowsersExcludingIE(); + } + + @Test + public void tooltipShouldBeStationary() throws InterruptedException { + openTestURL(); + + Mouse mouse = getMouse(); + + moveMouseToButtonUpperLeftCorner(mouse); + sleep(3000); // wait for the tooltip to become visible + int originalTooltipLocationX = getTooltipLocationX(); + + moveMouseToButtonBottomRightCorner(mouse); + int actualTooltipLocationX = getTooltipLocationX(); + + assertThat(actualTooltipLocationX, is(greaterThan(0))); + assertThat(actualTooltipLocationX, is(originalTooltipLocationX)); + } + + private Coordinates getButtonCoordinates() { + return getCoordinates(getButtonElement()); + } + + private ButtonElement getButtonElement() { + return $(ButtonElement.class).first(); + } + + private void moveMouseToButtonBottomRightCorner(Mouse mouse) { + Coordinates buttonCoordinates = getButtonCoordinates(); + Dimension buttonDimensions = getButtonDimensions(); + + mouse.mouseMove(buttonCoordinates, buttonDimensions.getWidth() - 1, + buttonDimensions.getHeight() - 1); + } + + private void moveMouseToButtonUpperLeftCorner(Mouse mouse) { + Coordinates buttonCoordinates = getButtonCoordinates(); + + mouse.mouseMove(buttonCoordinates, 0, 0); + } + + private org.openqa.selenium.Dimension getButtonDimensions() { + ButtonElement buttonElement = getButtonElement(); + + return buttonElement.getWrappedElement().getSize(); + } + + private int getTooltipLocationX() { + return getTooltipElement().getLocation().getX(); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/widgetset/client/AbstractSuperclassForBean.java b/uitest/src/com/vaadin/tests/widgetset/client/AbstractSuperclassForBean.java new file mode 100644 index 0000000000..0ea19bd965 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/AbstractSuperclassForBean.java @@ -0,0 +1,26 @@ +/* + * 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.widgetset.client; + +import java.io.Serializable; + +/** + * Dummy state bean used just to check that nothing breaks when generating code + * to serialize beans with properties in abstract superclasses + */ +public abstract class AbstractSuperclassForBean implements Serializable { + public String propertyInAbstractSuperclass; +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/BeanWithAbstractSuperclass.java b/uitest/src/com/vaadin/tests/widgetset/client/BeanWithAbstractSuperclass.java new file mode 100644 index 0000000000..a3530f19e9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/BeanWithAbstractSuperclass.java @@ -0,0 +1,24 @@ +/* + * 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.widgetset.client; + +/** + * Dummy state bean used just to check that nothing breaks when generating code + * to serialize beans with properties in abstract superclasses + */ +public class BeanWithAbstractSuperclass extends AbstractSuperclassForBean { + public String propertyInsubclass; +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java index d22165b2bb..faf41fbf88 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestState.java @@ -97,4 +97,6 @@ public class SerializerTestState extends AbstractComponentState { public Date date1; public Date date2; + public BeanWithAbstractSuperclass beanWithAbstractSuperclass; + } diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml index 6e0f25a8f7..a39725f1bb 100644 --- a/uitest/tb3test.xml +++ b/uitest/tb3test.xml @@ -7,6 +7,7 @@ <property name="browsers.exclude" value="" /> <property name="categories.include" value="" /> <property name="categories.exclude" value="" /> + <property name="useLocalWebDriver" value="false" /> <ivy:resolve file="${tb3test.dir}/ivy.xml" conf="build, build-provided" /> <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" /> @@ -37,6 +38,7 @@ <jvmarg value="-Dbrowsers.exclude=${browsers.exclude}" /> <jvmarg value="-Dcategories.include=${categories.include}" /> <jvmarg value="-Dcategories.exclude=${categories.exclude}" /> + <jvmarg value="-DuseLocalWebDriver=${useLocalWebDriver}" /> <test name="${junit.test.suite}" todir="${report.dir}" /> </junit> |