diff options
author | Heikki Ohinmaa <heikki@vaadin.com> | 2014-07-30 16:47:48 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-05 15:39:21 +0000 |
commit | 72ae78fc92656deb89deff752f2195d14158de45 (patch) | |
tree | 6ce0fb797e62728d6fe58ffe60a939f830b81360 /uitest | |
parent | cad11e69d203e303c7a7d2e329f044f319ecf72e (diff) | |
download | vaadin-framework-72ae78fc92656deb89deff752f2195d14158de45.tar.gz vaadin-framework-72ae78fc92656deb89deff752f2195d14158de45.zip |
Rewrite of a failing TB2 test to TB3.
Change-Id: Ic62e5f955d564d3d8f59ba7ca2a41d30e1a92452
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidth.java | 17 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java | 85 |
2 files changed, 90 insertions, 12 deletions
diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidth.java b/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidth.java index 89b03df92a..e8a2e10d9a 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidth.java +++ b/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidth.java @@ -1,15 +1,22 @@ package com.vaadin.tests.components.button; import com.vaadin.data.Item; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.NativeButton; import com.vaadin.ui.Table; -public class ButtonUndefinedWidth extends TestBase { +/** + * Test UI for buttons with undefined width. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class ButtonUndefinedWidth extends AbstractTestUI { @Override - protected String getDescription() { + protected String getTestDescription() { return "Both the button outside the table and inside the table should be only as wide as necessary. There should be empty space in the table to the right of the button."; } @@ -18,8 +25,9 @@ public class ButtonUndefinedWidth extends TestBase { return 3257; } + @SuppressWarnings("unchecked") @Override - protected void setup() { + protected void setup(VaadinRequest request) { Button b = new Button("Undefined wide"); addComponent(b); NativeButton b2 = new NativeButton("Undefined wide"); @@ -36,5 +44,4 @@ public class ButtonUndefinedWidth extends TestBase { addComponent(t); } - } diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java b/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java index 492f77c3f7..850dd1229c 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java +++ b/uitest/src/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java @@ -1,12 +1,12 @@ /* * 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 @@ -15,24 +15,95 @@ */ package com.vaadin.tests.components.button; -import java.io.IOException; +import java.util.List; +import org.junit.Assert; import org.junit.Test; +import org.openqa.selenium.WebElement; +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.NativeButtonElement; +import com.vaadin.testbench.elements.VerticalLayoutElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** * Validates button Widths for Buttons or Native Buttons, inside or outside * tables. * - * @since + * @since 7.2 * @author Vaadin Ltd */ public class ButtonUndefinedWidthTest extends MultiBrowserTest { @Test - public void undefinedButtonWidthTest() throws IOException { + public void undefinedButtonWidthTest() throws Exception { openTestURL(); - compareScreen("1"); + + // make sure all the elements are rendered before commencing tests + waitForElementVisible(By.className("v-table-row-odd")); + + // click all of the buttons + for (NativeButtonElement button : $(NativeButtonElement.class).all()) { + button.click(); + } + for (ButtonElement button : $(ButtonElement.class).all()) { + button.click(); + } + + // remove focus + getDriver().findElement(By.className("v-app")).click(); + + // check button widths in VerticalLayout + VerticalLayoutElement vLayout = $(VerticalLayoutElement.class).$( + VerticalLayoutElement.class).first(); + int containerWidth = vLayout.getSize().getWidth(); + + NativeButtonElement nativeButton = vLayout.$(NativeButtonElement.class) + .first(); + int buttonWidth = nativeButton.getSize().getWidth(); + + assertButtonWidth(buttonWidth, containerWidth); + + ButtonElement button = vLayout.$(ButtonElement.class).first(); + buttonWidth = button.getSize().getWidth(); + assertButtonWidth(buttonWidth, containerWidth); + + // check button widths in table, also make sure that there is some + // spacing between the table edges and buttons + List<WebElement> rows = findElements(By + .className("v-table-cell-content")); + int rowWidth = rows.get(0).getSize().getWidth(); + + List<WebElement> rowWrappers = findElements(By + .className("v-table-cell-wrapper")); + WebElement row = rowWrappers.get(0); + + containerWidth = row.getSize().getWidth(); + assertRowWrapperWidth(containerWidth, rowWidth); + + buttonWidth = row.findElement(By.className("v-button")).getSize() + .getWidth(); + assertButtonWidth(buttonWidth, containerWidth); + + row = rowWrappers.get(1); + containerWidth = row.getSize().getWidth(); + assertRowWrapperWidth(containerWidth, rowWidth); + + buttonWidth = row.findElement(By.className("v-nativebutton")).getSize() + .getWidth(); + assertButtonWidth(buttonWidth, containerWidth); + + } + + private void assertRowWrapperWidth(int wrapperWidth, int rowWidth) { + Assert.assertTrue("Wrapper should be narrower than its parent: " + + wrapperWidth + " < " + rowWidth, wrapperWidth < rowWidth); + } + + private void assertButtonWidth(int buttonWidth, int containerWidth) { + Assert.assertTrue("Button should be narrower than its parent: " + + buttonWidth + " < " + containerWidth, + buttonWidth < containerWidth); } } |