Browse Source

Update release note and since tag (#11386)

* Some formatting changes
tags/8.7.0.beta1
Sun Zhe 5 years ago
parent
commit
0cfbee6ed5
No account linked to committer's email address

+ 1
- 0
all/src/main/templates/release-notes.html View File

<ul> <ul>
<li>Add more context information to criteriaScript in <tt>GridDropTargetConnector</tt></li> <li>Add more context information to criteriaScript in <tt>GridDropTargetConnector</tt></li>
<li>Add support for <tt>FocusShortcutListener</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>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> <li>Performance improvements for the Vaadin 7 compatibility Grid, picked from the Vaadin 7 branch.</li>
</ul> </ul>

+ 2
- 1
client/src/main/java/com/vaadin/client/ui/VCheckBox.java View File

* Gives access to the input element. * Gives access to the input element.
* *
* @return Element of the CheckBox itself * @return Element of the CheckBox itself
* @since 8.7
*/ */
public Element getInputElement() { public Element getInputElement() {
// public to allow CheckBoxState to access it. // public to allow CheckBoxState to access it.
* Gives access to the label element. * Gives access to the label element.
* *
* @return Element of the Label itself * @return Element of the Label itself
* @since
* @since 8.7
*/ */
public Element getLabelElement() { public Element getLabelElement() {
// public to allow CheckBoxState to access it. // public to allow CheckBoxState to access it.

+ 10
- 7
client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java View File

*/ */
package com.vaadin.client.ui.checkbox; package com.vaadin.client.ui.checkbox;


import java.util.List;

import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.vaadin.shared.ui.checkbox.CheckBoxState; import com.vaadin.shared.ui.checkbox.CheckBoxState;
import com.vaadin.ui.CheckBox; import com.vaadin.ui.CheckBox;


import java.util.List;

/** /**
* The client-side connector for the {@code CheckBoxGroup} component. * The client-side connector for the {@code CheckBoxGroup} component.
* *
* The style names from getState().inputStyles which are currently applied * The style names from getState().inputStyles which are currently applied
* to the checkbox. * to the checkbox.
* *
* @since
* @since 8.7
*/ */
private JsArrayString inputStyleNames = JsArrayString.createArray().cast(); private JsArrayString inputStyleNames = JsArrayString.createArray().cast();


* The style names from getState().labelStyles which are currently applied * The style names from getState().labelStyles which are currently applied
* to the checkbox. * to the checkbox.
* *
* @since
* @since 8.7
*/ */
private JsArrayString labelStyleNames = JsArrayString.createArray().cast(); private JsArrayString labelStyleNames = JsArrayString.createArray().cast();


getWidget().setValue(getState().checked); getWidget().setValue(getState().checked);


// Set styles for input and label // 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 @Override
} }
} }


private void updateStyles(Element clientElement, JsArrayString clientSideStyles, List<String> serverSideStyes) {
private void updateStyles(Element clientElement,
JsArrayString clientSideStyles, List<String> serverSideStyes) {
// Remove all old stylenames // Remove all old stylenames
for (int i = 0; i < clientSideStyles.length(); i++) { for (int i = 0; i < clientSideStyles.length(); i++) {
clientElement.removeClassName(clientSideStyles.get(i)); clientElement.removeClassName(clientSideStyles.get(i));

+ 28
- 20
server/src/main/java/com/vaadin/ui/CheckBox.java View File



private final CheckBox checkBox; private final CheckBox checkBox;


private CheckBoxInputElement(CheckBox checkBox){
private CheckBoxInputElement(CheckBox checkBox) {
this.checkBox = checkBox; this.checkBox = checkBox;
} }


public String getStyleName() { public String getStyleName() {
// replaced String with StringBuilder // replaced String with StringBuilder
StringBuilder s = new 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()); s.append(it.next());
if (it.hasNext()) { if (it.hasNext()) {
s.append(" "); s.append(" ");
if (style == null || style.isEmpty()) { if (style == null || style.isEmpty()) {
return; return;
} }
if (checkBox.getState().inputStyles != null && checkBox.getState().inputStyles.contains(style)) {
if (checkBox.getState().inputStyles != null
&& checkBox.getState().inputStyles.contains(style)) {
return; return;
} }
if (style.contains(" ")) { if (style.contains(" ")) {
if (ComponentStateUtil.hasStyles(checkBox.getState().inputStyles)) { if (ComponentStateUtil.hasStyles(checkBox.getState().inputStyles)) {
StringTokenizer tokenizer = new StringTokenizer(style, " "); StringTokenizer tokenizer = new StringTokenizer(style, " ");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
checkBox.getState().inputStyles.remove(tokenizer.nextToken());
checkBox.getState().inputStyles
.remove(tokenizer.nextToken());
} }
} }
} }


private final CheckBox checkBox; private final CheckBox checkBox;


private CheckBoxLabelElement(CheckBox checkBox){
private CheckBoxLabelElement(CheckBox checkBox) {
this.checkBox = checkBox; this.checkBox = checkBox;
} }


public String getStyleName() { public String getStyleName() {
// replaced String with StringBuilder // replaced String with StringBuilder
StringBuilder s = new 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()); s.append(it.next());
if (it.hasNext()) { if (it.hasNext()) {
s.append(" "); s.append(" ");
if (style == null || style.isEmpty()) { if (style == null || style.isEmpty()) {
return; return;
} }
if (checkBox.getState().labelStyles != null && checkBox.getState().labelStyles.contains(style)) {
if (checkBox.getState().labelStyles != null
&& checkBox.getState().labelStyles.contains(style)) {
return; return;
} }
if (style.contains(" ")) { if (style.contains(" ")) {
if (ComponentStateUtil.hasStyles(checkBox.getState().labelStyles)) { if (ComponentStateUtil.hasStyles(checkBox.getState().labelStyles)) {
StringTokenizer tokenizer = new StringTokenizer(style, " "); StringTokenizer tokenizer = new StringTokenizer(style, " ");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
checkBox.getState().labelStyles.remove(tokenizer.nextToken());
checkBox.getState().labelStyles
.remove(tokenizer.nextToken());
} }
} }
} }
} }


/** /**
* 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}. * @return the current {@link CheckBoxInputElement}, not {@code null}.
*/ */
public CheckBoxInputElement getInputElement() { public CheckBoxInputElement getInputElement() {
if(checkBoxInputElement == null) {
if (checkBoxInputElement == null) {
checkBoxInputElement = new CheckBoxInputElement(this); checkBoxInputElement = new CheckBoxInputElement(this);
} }
return checkBoxInputElement; 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}. * @return the current {@link CheckBoxLabelElement}, not {@code null}.
*/ */
public CheckBoxLabelElement getLabelElement() { public CheckBoxLabelElement getLabelElement() {
if(checkBoxLabelElement == null) {
if (checkBoxLabelElement == null) {
checkBoxLabelElement = new CheckBoxLabelElement(this); checkBoxLabelElement = new CheckBoxLabelElement(this);
} }
return checkBoxLabelElement; return checkBoxLabelElement;

+ 10
- 10
server/src/main/java/com/vaadin/ui/HasStyleNames.java View File

* Implemented by components which support style names. * Implemented by components which support style names.
* *
* <p> * <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> * </p>
* *
* @since
* @since 8.7
*/ */
public interface HasStyleNames extends Serializable { public interface HasStyleNames extends Serializable {


* added. * added.
* </p> * </p>
* *
* @since
* @since 8.7
* @return the style name or a space-separated list of user-defined style * @return the style name or a space-separated list of user-defined style
* names of the component * names of the component
* @see #setStyleName(String) * @see #setStyleName(String)
* removing those defined in other layers. * removing those defined in other layers.
* </p> * </p>
* *
* @since
* @since 8.7
* @param style * @param style
* the new style or styles of the component as a space-separated * the new style or styles of the component as a space-separated
* list * list
* Functionally this is equivalent to using {@link #addStyleName(String)} or * Functionally this is equivalent to using {@link #addStyleName(String)} or
* {@link #removeStyleName(String)} * {@link #removeStyleName(String)}
* *
* @since
* @since 8.7
* @param style * @param style
* the style name to be added or removed * the style name to be added or removed
* @param add * @param add
* be rendered as a HTML class name, which can be used in a CSS definition. * be rendered as a HTML class name, which can be used in a CSS definition.
* *
* *
* @since
* @since 8.7
* @param style * @param style
* the new style to be added to the component * the new style to be added to the component
* @see #getStyleName() * @see #getStyleName()
* Adds one or more style names to this component by using one or multiple * Adds one or more style names to this component by using one or multiple
* parameters. * parameters.
* *
* @since
* @since 8.7
* @param styles * @param styles
* the style name or style names to be added to the component * the style name or style names to be added to the component
* @see #addStyleName(String) * @see #addStyleName(String)
* style names defined in Vaadin or GWT can not be removed. * style names defined in Vaadin or GWT can not be removed.
* </p> * </p>
* *
* @since
* @since 8.7
* @param style * @param style
* the style name or style names to be removed * the style name or style names to be removed
* @see #getStyleName() * @see #getStyleName()
* style names defined in Vaadin or GWT can not be removed. * style names defined in Vaadin or GWT can not be removed.
* </p> * </p>
* *
* @since
* @since 8.7
* @param styles * @param styles
* the style name or style names to be removed * the style name or style names to be removed
* @see #removeStyleName(String) * @see #removeStyleName(String)

+ 2
- 2
server/src/main/java/com/vaadin/ui/MenuBar.java View File

* {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)} * {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)}
* after mouseDownEvent * after mouseDownEvent
* *
* @since
* @since 8.7
*/ */
public int getDelayMs() { public int getDelayMs() {
return getState(false).delayMs; return getState(false).delayMs;
* {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)} * {@link com.vaadin.client.ui.menubar.MenuBarConnector#updateFromUIDL(UIDL, ApplicationConnection)}
* after mouseDownEvent * after mouseDownEvent
* *
* @since
* @since 8.7
*/ */
public void setDelayMs(int delayMs) { public void setDelayMs(int delayMs) {
getState().delayMs = delayMs; getState().delayMs = delayMs;

+ 28
- 23
server/src/test/java/com/vaadin/ui/CheckBoxTest.java View File

package com.vaadin.ui; 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 java.util.concurrent.atomic.AtomicBoolean;


import org.junit.Ignore; import org.junit.Ignore;
import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc; import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
import com.vaadin.tests.util.MockUI; 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 { public class CheckBoxTest {
@Test @Test
public void initiallyFalse() { public void initiallyFalse() {
@Test @Test
public void getComboBoxInput() { public void getComboBoxInput() {
CheckBox cb = new CheckBox(); 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()); assertHasStyleNames(cb.getInputElement());
} }


@Test @Test
public void getCheckBoxLabel() { public void getCheckBoxLabel() {
CheckBox cb = new CheckBox(); 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()); assertHasStyleNames(cb.getLabelElement());
} }


@Test @Test
@Ignore("Component#setStyleName(null, false) should not throw a NPE") @Ignore("Component#setStyleName(null, false) should not throw a NPE")
public void setStyleName_null_false_throws_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(); CheckBox cb = new CheckBox();
cb.getLabelElement().addStyleName("first"); cb.getLabelElement().addStyleName("first");
cb.getLabelElement().setStyleName(null, false); 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) { 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"); hasStyleNames.addStyleName("first");
assertEquals("first", hasStyleNames.getStyleName()); assertEquals("first", hasStyleNames.getStyleName());
"first", hasStyleNames.getStyleName()); "first", hasStyleNames.getStyleName());


hasStyleNames.addStyleName(null); 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(""); hasStyleNames.addStyleName("");
assertEquals("Adding an empty string as style should be ignored", assertEquals("Adding an empty string as style should be ignored",
hasStyleNames.addStyleNames("third", "fourth"); hasStyleNames.addStyleNames("third", "fourth");
assertEquals("first second third fourth", hasStyleNames.getStyleName()); assertEquals("first second third fourth", hasStyleNames.getStyleName());


hasStyleNames.removeStyleNames("second", "fourth");
hasStyleNames.removeStyleNames("second", "fourth");
assertEquals("first third", hasStyleNames.getStyleName()); assertEquals("first third", hasStyleNames.getStyleName());


hasStyleNames.setStyleName(null); 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"); hasStyleNames.setStyleName("set-style");
assertEquals("set-style", hasStyleNames.getStyleName()); assertEquals("set-style", hasStyleNames.getStyleName());


hasStyleNames.setStyleName(""); 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"); hasStyleNames.setStyleName("set-style multiple values");
assertEquals("set-style multiple values", hasStyleNames.getStyleName()); assertEquals("set-style multiple values", hasStyleNames.getStyleName());
"multiple values", hasStyleNames.getStyleName()); "multiple values", hasStyleNames.getStyleName());


hasStyleNames.setStyleName(null, true); 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); 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.getStyleName());


hasStyleNames.setStyleName("set-style", true); hasStyleNames.setStyleName("set-style", true);

+ 2
- 1
uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElement.java View File



@Override @Override
protected void setup(VaadinRequest request) { 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.getInputElement().addStyleName("my-input-class");
cb.getLabelElement().addStyleName("my-label-class"); cb.getLabelElement().addStyleName("my-label-class");



+ 7
- 5
uitest/src/main/java/com/vaadin/tests/components/grid/GridEditorScrollSync.java View File

package com.vaadin.tests.components.grid; package com.vaadin.tests.components.grid;

import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.v7.ui.Grid; import com.vaadin.v7.ui.Grid;

public class GridEditorScrollSync extends AbstractTestUI { public class GridEditorScrollSync extends AbstractTestUI {
@Override @Override
protected void setup(VaadinRequest request) { protected void setup(VaadinRequest request) {
grid.setWidth("450px"); grid.setWidth("450px");
// Add some data rows // Add some data rows
grid.addRow("Nicolaus Copernicus", 1543, "Nicolaus Copernicus", 1543, 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, 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, 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); getLayout().addComponent(grid);
} }
} }

+ 2
- 2
uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java View File

import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;


import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest; import com.vaadin.tests.tb3.SingleBrowserTest;


public class FocusShortcutsTest extends SingleBrowserTest { public class FocusShortcutsTest extends SingleBrowserTest {


actions = new Actions(getDriver()); actions = new Actions(getDriver());
actions.keyDown(body, Keys.LEFT_CONTROL).keyDown(body, Keys.LEFT_SHIFT) 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)); Assert.assertEquals("3. Ctrl+Shift+D", getLogRow(0));
} }

+ 28
- 17
uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxLabelInputElementTest.java View File

package com.vaadin.tests.components.checkbox; 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.ButtonElement;
import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.tests.tb3.MultiBrowserTest; 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 { public class CheckboxLabelInputElementTest extends MultiBrowserTest {




assertEquals("my-label-class", labelElem.getAttribute("class")); assertEquals("my-label-class", labelElem.getAttribute("class"));
assertEquals("my-input-class", inputElem.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(); $(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(); $(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(); $(ButtonElement.class).caption("remove-style-2").first().click();



+ 13
- 6
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java View File

package com.vaadin.tests.components.grid; 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.Assert;
import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.By; import org.openqa.selenium.By;

import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.MultiBrowserTest;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.IsCloseTo.closeTo;

public class GridEditorScrollSyncTest extends MultiBrowserTest { public class GridEditorScrollSyncTest extends MultiBrowserTest {
private GridElement grid; private GridElement grid;

@Test @Test
public void testScrollAndEdit() { public void testScrollAndEdit() {
openTestURL(); openTestURL();
grid = $(GridElement.class).first(); grid = $(GridElement.class).first();
((TestBenchElement) grid ((TestBenchElement) grid
.findElement(By.className("v-grid-scroller-horizontal")))
.scrollLeft(300);
.findElement(By.className("v-grid-scroller-horizontal")))
.scrollLeft(300);
openEditor(); openEditor();
GridElement.GridCellElement rowCell = grid.getCell(1, 6); GridElement.GridCellElement rowCell = grid.getCell(1, 6);
TestBenchElement editorField = grid.getEditor().getField(6); TestBenchElement editorField = grid.getEditor().getField(6);
assertPosition(rowCell.getLocation().getX(), assertPosition(rowCell.getLocation().getX(),
editorField.getWrappedElement().getLocation().getX());
editorField.getWrappedElement().getLocation().getX());
} }

private GridElement openEditor() { private GridElement openEditor() {
grid.getCell(0, 6).doubleClick(); grid.getCell(0, 6).doubleClick();
Assert.assertTrue("Grid editor should be displayed.", Assert.assertTrue("Grid editor should be displayed.",
grid.getEditor().isDisplayed());
grid.getEditor().isDisplayed());
return grid; return grid;
} }

private void assertPosition(double expected, double actual) { private void assertPosition(double expected, double actual) {
// 1px leeway for calculations // 1px leeway for calculations
assertThat("Unexpected position.", expected, closeTo(actual, 1d)); assertThat("Unexpected position.", expected, closeTo(actual, 1d));

Loading…
Cancel
Save