diff options
author | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2018-12-20 17:00:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-20 17:00:57 +0200 |
commit | 0cfbee6ed5663d928a31def30d111733eae93731 (patch) | |
tree | 0737483b3ca66322f9c7f4a06c2824c2d00bd26e | |
parent | 353ba29cfdefddb032122cbeae5f02f6d9de76ba (diff) | |
download | vaadin-framework-0cfbee6ed5663d928a31def30d111733eae93731.tar.gz vaadin-framework-0cfbee6ed5663d928a31def30d111733eae93731.zip |
Update release note and since tag (#11386)
* Some formatting changes
12 files changed, 133 insertions, 94 deletions
diff --git a/all/src/main/templates/release-notes.html b/all/src/main/templates/release-notes.html index cb453773c8..da41d879c8 100644 --- a/all/src/main/templates/release-notes.html +++ b/all/src/main/templates/release-notes.html @@ -85,6 +85,7 @@ <ul> <li>Add more context information to criteriaScript in <tt>GridDropTargetConnector</tt></li> <li>Add support for <tt>FocusShortcutListener</tt></li> + <li>Allow setting customised style to input and label elements in <tt>CheckBox</tt></li> <li>Allow empty selection to be displayed in <tt>NativeSelect</tt></li> <li>Performance improvements for the Vaadin 7 compatibility Grid, picked from the Vaadin 7 branch.</li> </ul> diff --git a/client/src/main/java/com/vaadin/client/ui/VCheckBox.java b/client/src/main/java/com/vaadin/client/ui/VCheckBox.java index f535086d94..d78f15ca76 100644 --- a/client/src/main/java/com/vaadin/client/ui/VCheckBox.java +++ b/client/src/main/java/com/vaadin/client/ui/VCheckBox.java @@ -83,6 +83,7 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox * Gives access to the input element. * * @return Element of the CheckBox itself + * @since 8.7 */ public Element getInputElement() { // public to allow CheckBoxState to access it. @@ -94,7 +95,7 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox * Gives access to the label element. * * @return Element of the Label itself - * @since + * @since 8.7 */ public Element getLabelElement() { // public to allow CheckBoxState to access it. diff --git a/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java index df9b9b11cf..361c971a07 100644 --- a/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java @@ -15,6 +15,8 @@ */ package com.vaadin.client.ui.checkbox; +import java.util.List; + import com.google.gwt.core.client.JsArrayString; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; @@ -38,8 +40,6 @@ import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc; import com.vaadin.shared.ui.checkbox.CheckBoxState; import com.vaadin.ui.CheckBox; -import java.util.List; - /** * The client-side connector for the {@code CheckBoxGroup} component. * @@ -54,7 +54,7 @@ public class CheckBoxConnector extends AbstractFieldConnector * The style names from getState().inputStyles which are currently applied * to the checkbox. * - * @since + * @since 8.7 */ private JsArrayString inputStyleNames = JsArrayString.createArray().cast(); @@ -62,7 +62,7 @@ public class CheckBoxConnector extends AbstractFieldConnector * The style names from getState().labelStyles which are currently applied * to the checkbox. * - * @since + * @since 8.7 */ private JsArrayString labelStyleNames = JsArrayString.createArray().cast(); @@ -111,8 +111,10 @@ public class CheckBoxConnector extends AbstractFieldConnector getWidget().setValue(getState().checked); // Set styles for input and label - updateStyles(getWidget().getInputElement(), inputStyleNames, getState().inputStyles); - updateStyles(getWidget().getLabelElement(), labelStyleNames, getState().labelStyles); + updateStyles(getWidget().getInputElement(), inputStyleNames, + getState().inputStyles); + updateStyles(getWidget().getLabelElement(), labelStyleNames, + getState().labelStyles); } @Override @@ -160,7 +162,8 @@ public class CheckBoxConnector extends AbstractFieldConnector } } - private void updateStyles(Element clientElement, JsArrayString clientSideStyles, List<String> serverSideStyes) { + private void updateStyles(Element clientElement, + JsArrayString clientSideStyles, List<String> serverSideStyes) { // Remove all old stylenames for (int i = 0; i < clientSideStyles.length(); i++) { clientElement.removeClassName(clientSideStyles.get(i)); diff --git a/server/src/main/java/com/vaadin/ui/CheckBox.java b/server/src/main/java/com/vaadin/ui/CheckBox.java index c0e259f330..0a54db5ccf 100644 --- a/server/src/main/java/com/vaadin/ui/CheckBox.java +++ b/server/src/main/java/com/vaadin/ui/CheckBox.java @@ -79,7 +79,7 @@ public class CheckBox extends AbstractField<Boolean> private final CheckBox checkBox; - private CheckBoxInputElement(CheckBox checkBox){ + private CheckBoxInputElement(CheckBox checkBox) { this.checkBox = checkBox; } @@ -88,9 +88,11 @@ public class CheckBox extends AbstractField<Boolean> public String getStyleName() { // replaced String with StringBuilder StringBuilder s = new StringBuilder(); - if (ComponentStateUtil.hasStyles(checkBox.getState(false).inputStyles)) { - for (final Iterator<String> it = checkBox.getState(false).inputStyles - .iterator(); it.hasNext();) { + if (ComponentStateUtil + .hasStyles(checkBox.getState(false).inputStyles)) { + for (final Iterator<String> it = checkBox + .getState(false).inputStyles.iterator(); it + .hasNext();) { s.append(it.next()); if (it.hasNext()) { s.append(" "); @@ -124,7 +126,8 @@ public class CheckBox extends AbstractField<Boolean> if (style == null || style.isEmpty()) { return; } - if (checkBox.getState().inputStyles != null && checkBox.getState().inputStyles.contains(style)) { + if (checkBox.getState().inputStyles != null + && checkBox.getState().inputStyles.contains(style)) { return; } if (style.contains(" ")) { @@ -149,7 +152,8 @@ public class CheckBox extends AbstractField<Boolean> if (ComponentStateUtil.hasStyles(checkBox.getState().inputStyles)) { StringTokenizer tokenizer = new StringTokenizer(style, " "); while (tokenizer.hasMoreTokens()) { - checkBox.getState().inputStyles.remove(tokenizer.nextToken()); + checkBox.getState().inputStyles + .remove(tokenizer.nextToken()); } } } @@ -162,7 +166,7 @@ public class CheckBox extends AbstractField<Boolean> private final CheckBox checkBox; - private CheckBoxLabelElement(CheckBox checkBox){ + private CheckBoxLabelElement(CheckBox checkBox) { this.checkBox = checkBox; } @@ -171,9 +175,11 @@ public class CheckBox extends AbstractField<Boolean> public String getStyleName() { // replaced String with StringBuilder StringBuilder s = new StringBuilder(); - if (ComponentStateUtil.hasStyles(checkBox.getState(false).labelStyles)) { - for (final Iterator<String> it = checkBox.getState(false).labelStyles - .iterator(); it.hasNext();) { + if (ComponentStateUtil + .hasStyles(checkBox.getState(false).labelStyles)) { + for (final Iterator<String> it = checkBox + .getState(false).labelStyles.iterator(); it + .hasNext();) { s.append(it.next()); if (it.hasNext()) { s.append(" "); @@ -207,7 +213,8 @@ public class CheckBox extends AbstractField<Boolean> if (style == null || style.isEmpty()) { return; } - if (checkBox.getState().labelStyles != null && checkBox.getState().labelStyles.contains(style)) { + if (checkBox.getState().labelStyles != null + && checkBox.getState().labelStyles.contains(style)) { return; } if (style.contains(" ")) { @@ -232,7 +239,8 @@ public class CheckBox extends AbstractField<Boolean> if (ComponentStateUtil.hasStyles(checkBox.getState().labelStyles)) { StringTokenizer tokenizer = new StringTokenizer(style, " "); while (tokenizer.hasMoreTokens()) { - checkBox.getState().labelStyles.remove(tokenizer.nextToken()); + checkBox.getState().labelStyles + .remove(tokenizer.nextToken()); } } } @@ -386,28 +394,28 @@ public class CheckBox extends AbstractField<Boolean> } /** - * Returns the {@link CheckBoxInputElement} element to manipulate - * the style name of the {@code input} element of the {@link CheckBox}. + * Returns the {@link CheckBoxInputElement} element to manipulate the style + * name of the {@code input} element of the {@link CheckBox}. * - * @since + * @since 8.7 * @return the current {@link CheckBoxInputElement}, not {@code null}. */ public CheckBoxInputElement getInputElement() { - if(checkBoxInputElement == null) { + if (checkBoxInputElement == null) { checkBoxInputElement = new CheckBoxInputElement(this); } return checkBoxInputElement; } /** - * Returns the {@link CheckBoxLabelElement} element to manipulate - * the style name of the {@code label} element of the {@link CheckBox}. + * Returns the {@link CheckBoxLabelElement} element to manipulate the style + * name of the {@code label} element of the {@link CheckBox}. * - * @since + * @since 8.7 * @return the current {@link CheckBoxLabelElement}, not {@code null}. */ public CheckBoxLabelElement getLabelElement() { - if(checkBoxLabelElement == null) { + if (checkBoxLabelElement == null) { checkBoxLabelElement = new CheckBoxLabelElement(this); } return checkBoxLabelElement; diff --git a/server/src/main/java/com/vaadin/ui/HasStyleNames.java b/server/src/main/java/com/vaadin/ui/HasStyleNames.java index 953711b1e6..2485c57597 100644 --- a/server/src/main/java/com/vaadin/ui/HasStyleNames.java +++ b/server/src/main/java/com/vaadin/ui/HasStyleNames.java @@ -21,11 +21,11 @@ import java.io.Serializable; * Implemented by components which support style names. * * <p> - * Each style name will occur only once as specified and it is not - * prefixed with the style name of the component. + * Each style name will occur only once as specified and it is not prefixed with + * the style name of the component. * </p> * - * @since + * @since 8.7 */ public interface HasStyleNames extends Serializable { @@ -40,7 +40,7 @@ public interface HasStyleNames extends Serializable { * added. * </p> * - * @since + * @since 8.7 * @return the style name or a space-separated list of user-defined style * names of the component * @see #setStyleName(String) @@ -62,7 +62,7 @@ public interface HasStyleNames extends Serializable { * removing those defined in other layers. * </p> * - * @since + * @since 8.7 * @param style * the new style or styles of the component as a space-separated * list @@ -83,7 +83,7 @@ public interface HasStyleNames extends Serializable { * Functionally this is equivalent to using {@link #addStyleName(String)} or * {@link #removeStyleName(String)} * - * @since + * @since 8.7 * @param style * the style name to be added or removed * @param add @@ -106,7 +106,7 @@ public interface HasStyleNames extends Serializable { * be rendered as a HTML class name, which can be used in a CSS definition. * * - * @since + * @since 8.7 * @param style * the new style to be added to the component * @see #getStyleName() @@ -119,7 +119,7 @@ public interface HasStyleNames extends Serializable { * Adds one or more style names to this component by using one or multiple * parameters. * - * @since + * @since 8.7 * @param styles * the style name or style names to be added to the component * @see #addStyleName(String) @@ -143,7 +143,7 @@ public interface HasStyleNames extends Serializable { * style names defined in Vaadin or GWT can not be removed. * </p> * - * @since + * @since 8.7 * @param style * the style name or style names to be removed * @see #getStyleName() @@ -163,7 +163,7 @@ public interface HasStyleNames extends Serializable { * style names defined in Vaadin or GWT can not be removed. * </p> * - * @since + * @since 8.7 * @param styles * the style name or style names to be removed * @see #removeStyleName(String) diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java index ce43802cc5..137e6ea522 100644 --- a/server/src/main/java/com/vaadin/ui/MenuBar.java +++ b/server/src/main/java/com/vaadin/ui/MenuBar.java @@ -455,7 +455,7 @@ public class MenuBar extends AbstractComponent * {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)} * after mouseDownEvent * - * @since + * @since 8.7 */ public int getDelayMs() { return getState(false).delayMs; @@ -466,7 +466,7 @@ public class MenuBar extends AbstractComponent * {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)} * after mouseDownEvent * - * @since + * @since 8.7 */ public void setDelayMs(int delayMs) { getState().delayMs = delayMs; diff --git a/server/src/test/java/com/vaadin/ui/CheckBoxTest.java b/server/src/test/java/com/vaadin/ui/CheckBoxTest.java index 0fbd6fa694..c9c8b84465 100644 --- a/server/src/test/java/com/vaadin/ui/CheckBoxTest.java +++ b/server/src/test/java/com/vaadin/ui/CheckBoxTest.java @@ -1,10 +1,5 @@ package com.vaadin.ui; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Ignore; @@ -15,6 +10,11 @@ import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc; import com.vaadin.tests.util.MockUI; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class CheckBoxTest { @Test public void initiallyFalse() { @@ -74,32 +74,36 @@ public class CheckBoxTest { @Test public void getComboBoxInput() { CheckBox cb = new CheckBox(); - assertNotNull("getInputElement should always return a element", cb.getInputElement()); + assertNotNull("getInputElement should always return a element", + cb.getInputElement()); assertHasStyleNames(cb.getInputElement()); } @Test public void getCheckBoxLabel() { CheckBox cb = new CheckBox(); - assertNotNull("getLabelElement should always return a element", cb.getLabelElement()); + assertNotNull("getLabelElement should always return a element", + cb.getLabelElement()); assertHasStyleNames(cb.getLabelElement()); } @Test @Ignore("Component#setStyleName(null, false) should not throw a NPE") public void setStyleName_null_false_throws_NPE() { - // FIXME? - Currently it throws a NPE like the implementation in Component.java - // waiting for other ticket that fixes the behaviour in Component.java before + // FIXME? - Currently it throws a NPE like the implementation in + // Component.java + // waiting for other ticket that fixes the behaviour in Component.java + // before CheckBox cb = new CheckBox(); cb.getLabelElement().addStyleName("first"); cb.getLabelElement().setStyleName(null, false); - assertEquals("Removing a null style should be ignored", - "first", cb.getLabelElement().getStyleName()); + assertEquals("Removing a null style should be ignored", "first", + cb.getLabelElement().getStyleName()); } private void assertHasStyleNames(HasStyleNames hasStyleNames) { - assertEquals("Given element should not have a default style name", - "", hasStyleNames.getStyleName()); + assertEquals("Given element should not have a default style name", "", + hasStyleNames.getStyleName()); hasStyleNames.addStyleName("first"); assertEquals("first", hasStyleNames.getStyleName()); @@ -109,8 +113,8 @@ public class CheckBoxTest { "first", hasStyleNames.getStyleName()); hasStyleNames.addStyleName(null); - assertEquals("Adding null as style should be ignored", - "first", hasStyleNames.getStyleName()); + assertEquals("Adding null as style should be ignored", "first", + hasStyleNames.getStyleName()); hasStyleNames.addStyleName(""); assertEquals("Adding an empty string as style should be ignored", @@ -131,19 +135,19 @@ public class CheckBoxTest { hasStyleNames.addStyleNames("third", "fourth"); assertEquals("first second third fourth", hasStyleNames.getStyleName()); - hasStyleNames.removeStyleNames("second", "fourth"); + hasStyleNames.removeStyleNames("second", "fourth"); assertEquals("first third", hasStyleNames.getStyleName()); hasStyleNames.setStyleName(null); - assertEquals("Setting null as style should reset them", - "", hasStyleNames.getStyleName()); + assertEquals("Setting null as style should reset them", "", + hasStyleNames.getStyleName()); hasStyleNames.setStyleName("set-style"); assertEquals("set-style", hasStyleNames.getStyleName()); hasStyleNames.setStyleName(""); - assertEquals("Setting an empty string as style should reset them", - "", hasStyleNames.getStyleName()); + assertEquals("Setting an empty string as style should reset them", "", + hasStyleNames.getStyleName()); hasStyleNames.setStyleName("set-style multiple values"); assertEquals("set-style multiple values", hasStyleNames.getStyleName()); @@ -160,11 +164,12 @@ public class CheckBoxTest { "multiple values", hasStyleNames.getStyleName()); hasStyleNames.setStyleName(null, true); - assertEquals("Adding a null style should be ignored", - "multiple values", hasStyleNames.getStyleName()); + assertEquals("Adding a null style should be ignored", "multiple values", + hasStyleNames.getStyleName()); hasStyleNames.setStyleName("multiple values", false); - assertEquals("Removing all set style names should result in an empty style name", + assertEquals( + "Removing all set style names should result in an empty style name", "", hasStyleNames.getStyleName()); hasStyleNames.setStyleName("set-style", true); diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElement.java b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElement.java index 248f214d1b..acdb88b32a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElement.java +++ b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElement.java @@ -8,7 +8,8 @@ public class CheckboxLabelInputElement extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - final CheckBox cb = new CheckBox("Test custom style names for inner elements", true); + final CheckBox cb = new CheckBox( + "Test custom style names for inner elements", true); cb.getInputElement().addStyleName("my-input-class"); cb.getLabelElement().addStyleName("my-label-class"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorScrollSync.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorScrollSync.java index 2d93403926..661e23dd21 100755 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorScrollSync.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorScrollSync.java @@ -1,7 +1,9 @@ package com.vaadin.tests.components.grid; + import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.v7.ui.Grid; + public class GridEditorScrollSync extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { @@ -23,13 +25,13 @@ public class GridEditorScrollSync extends AbstractTestUI { grid.setWidth("450px"); // Add some data rows grid.addRow("Nicolaus Copernicus", 1543, "Nicolaus Copernicus", 1543, - "Nicolaus Copernicus", 1543, "Nicolaus Copernicus", 1543, - "Nicolaus Copernicus", 1543); + "Nicolaus Copernicus", 1543, "Nicolaus Copernicus", 1543, + "Nicolaus Copernicus", 1543); grid.addRow("Galileo Galilei", 1564, "Galileo Galilei", 1564, - "Galileo Galilei", 1564, "s", 55, "Nicolaus Copernicus", 1543); + "Galileo Galilei", 1564, "s", 55, "Nicolaus Copernicus", 1543); grid.addRow("Johannes Kepler", 1571, "Johannes Kepler", 1571, - "Johannes Kepler", 1571, "Nicolaus Copernicus", 1543, - "Nicolaus Copernicus", 1543); + "Johannes Kepler", 1571, "Nicolaus Copernicus", 1543, + "Nicolaus Copernicus", 1543); getLayout().addComponent(grid); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java b/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java index e67b8d3240..92ba65d043 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java @@ -7,7 +7,6 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; -import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.SingleBrowserTest; public class FocusShortcutsTest extends SingleBrowserTest { @@ -35,7 +34,8 @@ public class FocusShortcutsTest extends SingleBrowserTest { actions = new Actions(getDriver()); actions.keyDown(body, Keys.LEFT_CONTROL).keyDown(body, Keys.LEFT_SHIFT) - .sendKeys("d").keyUp(Keys.LEFT_CONTROL).keyUp(Keys.LEFT_SHIFT).build().perform(); + .sendKeys("d").keyUp(Keys.LEFT_CONTROL).keyUp(Keys.LEFT_SHIFT) + .build().perform(); Assert.assertEquals("3. Ctrl+Shift+D", getLogRow(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElementTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElementTest.java index 16ac7ee1fc..7b83ecc120 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElementTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElementTest.java @@ -1,14 +1,15 @@ package com.vaadin.tests.components.checkbox; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +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.CheckBoxElement; import com.vaadin.tests.tb3.MultiBrowserTest; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class CheckboxLabelInputElementTest extends MultiBrowserTest { @@ -21,24 +22,34 @@ public class CheckboxLabelInputElementTest extends MultiBrowserTest { assertEquals("my-label-class", labelElem.getAttribute("class")); assertEquals("my-input-class", inputElem.getAttribute("class")); - assertTrue("The Checkbox Widget should not contain the classes that are " + - "defined as style names for the input or label.", - !checkBoxElement.getAttribute("class").contains("my-label-class") && - !checkBoxElement.getAttribute("class").contains("my-input-class")); + assertTrue( + "The Checkbox Widget should not contain the classes that are " + + "defined as style names for the input or label.", + !checkBoxElement.getAttribute("class") + .contains("my-label-class") + && !checkBoxElement.getAttribute("class") + .contains("my-input-class")); $(ButtonElement.class).caption("add-style").first().click(); - assertEquals("my-label-class later-applied-label-class", labelElem.getAttribute("class")); - assertEquals("my-input-class later-applied-input-class", inputElem.getAttribute("class")); - assertTrue("The Checkbox Widget should not contain the classes that are " + - "defined as style names for the input or label.", - !checkBoxElement.getAttribute("class").contains("later-applied-label-class") && - !checkBoxElement.getAttribute("class").contains("later-applied-input-class")); + assertEquals("my-label-class later-applied-label-class", + labelElem.getAttribute("class")); + assertEquals("my-input-class later-applied-input-class", + inputElem.getAttribute("class")); + assertTrue( + "The Checkbox Widget should not contain the classes that are " + + "defined as style names for the input or label.", + !checkBoxElement.getAttribute("class") + .contains("later-applied-label-class") + && !checkBoxElement.getAttribute("class") + .contains("later-applied-input-class")); $(ButtonElement.class).caption("remove-style").first().click(); - assertEquals("later-applied-label-class", labelElem.getAttribute("class")); - assertEquals("later-applied-input-class", inputElem.getAttribute("class")); + assertEquals("later-applied-label-class", + labelElem.getAttribute("class")); + assertEquals("later-applied-input-class", + inputElem.getAttribute("class")); $(ButtonElement.class).caption("remove-style-2").first().click(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java index 33297bdbf9..9c0c7360ee 100755 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java @@ -1,33 +1,40 @@ package com.vaadin.tests.components.grid; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.number.IsCloseTo.closeTo; + import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; + import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elements.GridElement; import com.vaadin.tests.tb3.MultiBrowserTest; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.number.IsCloseTo.closeTo; + public class GridEditorScrollSyncTest extends MultiBrowserTest { private GridElement grid; + @Test public void testScrollAndEdit() { openTestURL(); grid = $(GridElement.class).first(); ((TestBenchElement) grid - .findElement(By.className("v-grid-scroller-horizontal"))) - .scrollLeft(300); + .findElement(By.className("v-grid-scroller-horizontal"))) + .scrollLeft(300); openEditor(); GridElement.GridCellElement rowCell = grid.getCell(1, 6); TestBenchElement editorField = grid.getEditor().getField(6); assertPosition(rowCell.getLocation().getX(), - editorField.getWrappedElement().getLocation().getX()); + editorField.getWrappedElement().getLocation().getX()); } + private GridElement openEditor() { grid.getCell(0, 6).doubleClick(); Assert.assertTrue("Grid editor should be displayed.", - grid.getEditor().isDisplayed()); + grid.getEditor().isDisplayed()); return grid; } + private void assertPosition(double expected, double actual) { // 1px leeway for calculations assertThat("Unexpected position.", expected, closeTo(actual, 1d)); |