@@ -42,6 +42,7 @@ import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.EventListener; | |||
import com.google.gwt.user.client.Window; | |||
import com.google.gwt.user.client.ui.RootPanel; | |||
import com.google.gwt.user.client.ui.TextBox; | |||
import com.google.gwt.user.client.ui.Widget; | |||
import com.vaadin.shared.ui.ErrorLevel; | |||
import com.vaadin.shared.util.SharedUtil; | |||
@@ -1962,4 +1963,25 @@ public class WidgetUtil { | |||
return indicator; | |||
} | |||
} | |||
public static void disableBrowserAutocomplete(TextBox textBox) { | |||
/*- | |||
* Stop the browser from showing its own suggestion popup. | |||
* | |||
* Using an invalid value instead of "off" as suggested by | |||
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion | |||
* | |||
* Leaving the non-standard Safari options autocapitalize and | |||
* autocorrect untouched since those do not interfere in the same | |||
* way, and they might be useful in a combo box where new items are | |||
* allowed. | |||
*/ | |||
if (BrowserInfo.get().isChrome()) { | |||
// Chrome supports "off" and random number does not work with | |||
// Chrome | |||
textBox.getElement().setAttribute("autocomplete", "off"); | |||
} else { | |||
textBox.getElement().setAttribute("autocomplete", Math.random() + ""); | |||
} | |||
} | |||
} |
@@ -36,6 +36,7 @@ import com.vaadin.client.BrowserInfo; | |||
import com.vaadin.client.Focusable; | |||
import com.vaadin.client.LocaleNotLoadedException; | |||
import com.vaadin.client.LocaleService; | |||
import com.vaadin.client.WidgetUtil; | |||
import com.vaadin.client.ui.aria.AriaHelper; | |||
import com.vaadin.client.ui.aria.HandlesAriaCaption; | |||
import com.vaadin.client.ui.aria.HandlesAriaInvalid; | |||
@@ -90,6 +91,8 @@ public abstract class VAbstractTextualDate<R extends Enum<R>> | |||
if (BrowserInfo.get().isIE()) { | |||
addDomHandler(this, KeyDownEvent.getType()); | |||
} | |||
// Stop the browser from showing its own suggestion popup. | |||
WidgetUtil.disableBrowserAutocomplete(text); | |||
add(text); | |||
publishJSHelpers(getElement()); | |||
} |
@@ -1438,24 +1438,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
* @since 7.6.4 | |||
*/ | |||
public FilterSelectTextBox() { | |||
/*- | |||
* Stop the browser from showing its own suggestion popup. | |||
* | |||
* Using an invalid value instead of "off" as suggested by | |||
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion | |||
* | |||
* Leaving the non-standard Safari options autocapitalize and | |||
* autocorrect untouched since those do not interfere in the same | |||
* way, and they might be useful in a combo box where new items are | |||
* allowed. | |||
*/ | |||
if (BrowserInfo.get().isChrome()) { | |||
// Chrome supports "off" and random number does not work with | |||
// Chrome | |||
getElement().setAttribute("autocomplete", "off"); | |||
} else { | |||
getElement().setAttribute("autocomplete", Math.random() + ""); | |||
} | |||
WidgetUtil.disableBrowserAutocomplete(this); | |||
} | |||
/** | |||
@@ -2045,6 +2028,9 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
/** For internal use only. May be removed or replaced in the future. */ | |||
public void updateReadOnly() { | |||
if (readonly) { | |||
suggestionPopup.hide(); | |||
} | |||
debug("VComboBox: updateReadOnly()"); | |||
tb.setReadOnly(readonly || !textInputEnabled); | |||
} |
@@ -1409,23 +1409,8 @@ public class VFilterSelect extends Composite | |||
* @since 7.6.4 | |||
*/ | |||
public FilterSelectTextBox() { | |||
/*- | |||
* Stop the browser from showing its own suggestion popup. | |||
* | |||
* Using an invalid value instead of "off" as suggested by | |||
* https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion | |||
* | |||
* Leaving the non-standard Safari options autocapitalize and | |||
* autocorrect untouched since those do not interfere in the same | |||
* way, and they might be useful in a combo box where new items are | |||
* allowed. | |||
*/ | |||
if (BrowserInfo.get().isChrome()) { | |||
// Chrome supports "off" and random number does not work with Chrome | |||
getElement().setAttribute("autocomplete", "off"); | |||
} else { | |||
getElement().setAttribute("autocomplete", Math.random() + ""); | |||
} | |||
// Stop the browser from showing its own suggestion popup. | |||
WidgetUtil.disableBrowserAutocomplete(this); | |||
} | |||
/** |
@@ -349,6 +349,8 @@ public class VScrollTable extends FlowPanel | |||
private SelectMode selectMode = SelectMode.NONE; | |||
private boolean multiSelectTouchDetectionEnabled = true; | |||
public final HashSet<String> selectedRowKeys = new HashSet<String>(); | |||
/* | |||
@@ -1502,6 +1504,10 @@ public class VScrollTable extends FlowPanel | |||
} else { | |||
selectMode = SelectMode.NONE; | |||
} | |||
if (uidl.hasAttribute("touchdetection")) { | |||
multiSelectTouchDetectionEnabled = uidl | |||
.getBooleanAttribute("touchdetection"); | |||
} | |||
} | |||
} | |||
@@ -1951,9 +1957,10 @@ public class VScrollTable extends FlowPanel | |||
} | |||
private void setMultiSelectMode(int multiselectmode) { | |||
if (BrowserInfo.get().isTouchDevice()) { | |||
if (BrowserInfo.get().isTouchDevice() | |||
&& multiSelectTouchDetectionEnabled) { | |||
// Always use the simple mode for touch devices that do not have | |||
// shift/ctrl keys | |||
// shift/ctrl keys (unless this feature is explicitly disabled) | |||
this.multiselectmode = MULTISELECT_MODE_SIMPLE; | |||
} else { | |||
this.multiselectmode = multiselectmode; |
@@ -35,6 +35,7 @@ import com.vaadin.client.BrowserInfo; | |||
import com.vaadin.client.Focusable; | |||
import com.vaadin.client.LocaleNotLoadedException; | |||
import com.vaadin.client.LocaleService; | |||
import com.vaadin.client.WidgetUtil; | |||
import com.vaadin.client.ui.SubPartAware; | |||
import com.vaadin.client.ui.aria.AriaHelper; | |||
import com.vaadin.client.ui.aria.HandlesAriaCaption; | |||
@@ -115,6 +116,8 @@ public class VTextualDate extends VDateField | |||
if (BrowserInfo.get().isIE()) { | |||
addDomHandler(this, KeyDownEvent.getType()); | |||
} | |||
// Stop the browser from showing its own suggestion popup. | |||
WidgetUtil.disableBrowserAutocomplete(text); | |||
add(text); | |||
} | |||
@@ -620,7 +620,9 @@ public class ComboBox extends AbstractSelect | |||
// page length usable for non-null items | |||
int effectivePageLength = pageLength | |||
- (needNullSelectOption && (currentPage == 0) ? 1 : 0); | |||
return Math.min(size - 1, first + effectivePageLength - 1); | |||
// zero pageLength implies infinite page size | |||
return pageLength == 0 ? size - 1 | |||
: Math.min(size - 1, first + effectivePageLength - 1); | |||
} | |||
/** |
@@ -38,6 +38,7 @@ import java.util.Set; | |||
import java.util.logging.Level; | |||
import java.util.logging.Logger; | |||
import org.jsoup.Jsoup; | |||
import org.jsoup.nodes.Attributes; | |||
import org.jsoup.nodes.Element; | |||
import org.jsoup.select.Elements; | |||
@@ -3473,6 +3474,7 @@ public class Grid extends AbstractComponent | |||
if (caption == null) { | |||
caption = ""; // Render null as empty | |||
} | |||
caption = Jsoup.parse(caption).text(); | |||
state.headerCaption = caption; | |||
HeaderRow row = grid.getHeader().getDefaultRow(); |
@@ -588,6 +588,8 @@ public class Table extends AbstractSelect implements Action.Container, | |||
private MultiSelectMode multiSelectMode = MultiSelectMode.DEFAULT; | |||
private boolean multiSelectTouchDetectionEnabled = true; | |||
private boolean rowCacheInvalidated; | |||
private RowGenerator rowGenerator = null; | |||
@@ -3775,6 +3777,10 @@ public class Table extends AbstractSelect implements Action.Container, | |||
if (isSelectable()) { | |||
target.addAttribute("selectmode", | |||
(isMultiSelect() ? "multi" : "single")); | |||
if (isMultiSelect()) { | |||
target.addAttribute("touchdetection", | |||
isMultiSelectTouchDetectionEnabled()); | |||
} | |||
} else { | |||
target.addAttribute("selectmode", "none"); | |||
} | |||
@@ -5188,7 +5194,10 @@ public class Table extends AbstractSelect implements Action.Container, | |||
* <p> | |||
* Note, that on some clients the mode may not be respected. E.g. on touch | |||
* based devices CTRL/SHIFT base selection method is invalid, so touch based | |||
* browsers always use the {@link MultiSelectMode#SIMPLE}. | |||
* browsers always use the {@link MultiSelectMode#SIMPLE} unless touch multi | |||
* select is explicitly disabled. | |||
* | |||
* @see #setMultiSelectTouchDetectionEnabled(boolean) | |||
* | |||
* @param mode | |||
* The select mode of the table | |||
@@ -5207,6 +5216,31 @@ public class Table extends AbstractSelect implements Action.Container, | |||
return multiSelectMode; | |||
} | |||
/** | |||
* Default behavior on touch-reporting devices is to switch from CTRL/SHIFT | |||
* based multi-selection to simple mode, but you can use this method to | |||
* explicitly disable the touch device detection. Thus you can keep using | |||
* keyboard-based multi selection on hybrid devices that have both a touch | |||
* screen and a keyboard. | |||
* | |||
* @param multiSelectTouchDetectionEnabled | |||
* Whether to enable or disable touch screen detection | |||
*/ | |||
public void setMultiSelectTouchDetectionEnabled( | |||
boolean multiSelectTouchDetectionEnabled) { | |||
this.multiSelectTouchDetectionEnabled = multiSelectTouchDetectionEnabled; | |||
markAsDirty(); | |||
} | |||
/** | |||
* Returns if touch screen detection is used to toggle multi select mode. | |||
* | |||
* @return If touch screen detection for multi select is enabled | |||
*/ | |||
public boolean isMultiSelectTouchDetectionEnabled() { | |||
return multiSelectTouchDetectionEnabled; | |||
} | |||
/** | |||
* Lazy loading accept criterion for Table. Accepted target rows are loaded | |||
* from server once per drag and drop operation. Developer must override one |
@@ -137,6 +137,7 @@ | |||
} | |||
.#{$primaryStyleName}-body { | |||
border: 1px solid #aaa; | |||
overflow-anchor: none; /* In Chrome 56+ */ | |||
} | |||
.#{$primaryStyleName}-row-spacer { | |||
height: 10px; |
@@ -268,6 +268,7 @@ $v-table-background-color: null !default; | |||
.#{$primary-stylename}-body { | |||
border: $v-table-border-width solid $border-color; | |||
overflow-anchor: none; /* In Chrome 56+ */ | |||
@include user-select(text); | |||
} | |||
@@ -0,0 +1,45 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import com.vaadin.event.ShortcutAction; | |||
import com.vaadin.event.ShortcutListener; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
import com.vaadin.ui.ComboBox; | |||
public class ComboBoxReadOnlyPopup extends AbstractReindeerTestUI { | |||
static final String[] ITEMS = { "First", "Second", "Third" }; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
String boxLabel = String | |||
.format("Press 'Q' to toggle ComboBox's read-only mode"); | |||
final ComboBox<String> comboBox = new ComboBox<>(boxLabel); | |||
comboBox.setItems(ITEMS); | |||
comboBox.setSelectedItem(ITEMS[0]); | |||
ShortcutListener shortcutListener = new ShortcutListener("", null, | |||
ShortcutAction.KeyCode.Q) { | |||
@Override | |||
public void handleAction(Object sender, Object target) { | |||
comboBox.setReadOnly(!comboBox.isReadOnly()); | |||
} | |||
}; | |||
comboBox.addShortcutListener(shortcutListener); | |||
addComponents(comboBox); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "ComboBox that turns to read-only mode while expanded " | |||
+ "should have its popup set to hidden."; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 12021; | |||
} | |||
} |
@@ -10,9 +10,10 @@ import com.vaadin.v7.ui.Table.TableDragMode; | |||
@SuppressWarnings("serial") | |||
public class CtrlShiftMultiselect extends TestBase { | |||
protected final Table table = new Table("Multiselectable table"); | |||
@Override | |||
protected void setup() { | |||
final Table table = new Table("Multiselectable table"); | |||
table.setContainerDataSource(createContainer()); | |||
table.setImmediate(true); |
@@ -0,0 +1,41 @@ | |||
package com.vaadin.tests.components.table; | |||
import java.util.Set; | |||
import com.vaadin.v7.data.Property; | |||
import com.vaadin.v7.ui.Label; | |||
public class CtrlShiftMultiselectTouchDetectionDisabled | |||
extends CtrlShiftMultiselect { | |||
protected Label label; | |||
@Override | |||
protected void setup() { | |||
super.setup(); | |||
label = new Label("0"); | |||
label.setId("count"); | |||
label.setCaption("Amount of selected items"); | |||
table.setMultiSelectTouchDetectionEnabled(false); | |||
table.addValueChangeListener(new Property.ValueChangeListener() { | |||
@Override | |||
public void valueChange(Property.ValueChangeEvent event) { | |||
Property property = event.getProperty(); | |||
Set set = (Set) property.getValue(); | |||
label.setValue("" + set.size()); | |||
} | |||
}); | |||
addComponent(label); | |||
} | |||
@Override | |||
protected String getDescription() { | |||
return "Allow disabling multi selection's touch screen detection for hybrid devices"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 11601; | |||
} | |||
} |
@@ -0,0 +1,86 @@ | |||
package com.vaadin.tests.components.table; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.VerticalLayout; | |||
import com.vaadin.v7.data.util.BeanItemContainer; | |||
import com.vaadin.v7.ui.Table; | |||
public class TableScrollsOnRefresh extends AbstractTestUI { | |||
private Table table = new Table( | |||
"scroll down table, so it loads next page, and then click 'refresh' button"); | |||
private Button refresh = new Button("refresh"); | |||
private BeanItemContainer<TableItem> container = new BeanItemContainer<TableItem>( | |||
TableItem.class); | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
refresh.addClickListener(new Button.ClickListener() { | |||
@Override | |||
public void buttonClick(Button.ClickEvent event) { | |||
table.refreshRowCache(); | |||
} | |||
}); | |||
table.setSizeFull(); | |||
addComponents(refresh, table); | |||
VerticalLayout vl = getLayout(); | |||
vl.setExpandRatio(table, 1f); | |||
vl.setSizeFull(); | |||
vl.getParent().setSizeFull(); | |||
table.setContainerDataSource(container); | |||
populateContainer(); | |||
} | |||
private void populateContainer() { | |||
List<TableItem> items = new ArrayList<TableItem>(); | |||
for (int i = 0; i < 1000; i++) { | |||
items.add(new TableItem("Item " + Integer.toString(i), | |||
"Item description " + Integer.toString(i))); | |||
} | |||
container.addAll(items); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Refreshing row cache shouldn't change scroll position."; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 8707; | |||
} | |||
public class TableItem { | |||
private String name; | |||
private String description; | |||
public TableItem(String name, String description) { | |||
this.name = name; | |||
this.description = description; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public String getDescription() { | |||
return description; | |||
} | |||
public void setDescription(String description) { | |||
this.description = description; | |||
} | |||
} | |||
} |
@@ -0,0 +1,64 @@ | |||
package com.vaadin.tests.components.treetable; | |||
import static com.vaadin.server.Sizeable.Unit.PIXELS; | |||
import java.util.Set; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.data.Property; | |||
import com.vaadin.v7.ui.Label; | |||
import com.vaadin.v7.ui.TreeTable; | |||
public class TreeTableMultiselect extends AbstractTestUI { | |||
protected final TreeTable tt = new TreeTable("Multiselectable treetable"); | |||
protected Label label; | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
label = new Label("0"); | |||
label.setCaption("Amount of selected items"); | |||
label.setId("count"); | |||
tt.setImmediate(true); | |||
tt.addContainerProperty("Foo", String.class, ""); | |||
tt.setColumnWidth("Foo", 100); | |||
tt.addContainerProperty("Bar", String.class, ""); | |||
tt.setColumnWidth("Bar", 100); | |||
tt.setHeight(400, PIXELS); | |||
Object item1 = tt.addItem(new Object[] { "Foo", "Bar" }, null); | |||
Object item2 = tt.addItem(new Object[] { "Foo2", "Bar2" }, null); | |||
Object item3 = tt.addItem(new Object[] { "Foo3", "Bar3" }, null); | |||
tt.setParent(item2, item1); | |||
tt.setParent(item3, item1); | |||
tt.setCollapsed(item1, false); | |||
tt.setSelectable(true); | |||
tt.setMultiSelect(true); | |||
tt.setMultiSelectTouchDetectionEnabled(false); | |||
tt.setWidth("400px"); | |||
tt.setHeight("400px"); | |||
tt.addValueChangeListener(new Property.ValueChangeListener() { | |||
@Override | |||
public void valueChange(Property.ValueChangeEvent event) { | |||
Property property = event.getProperty(); | |||
Set set = (Set) property.getValue(); | |||
label.setValue("" + set.size()); | |||
} | |||
}); | |||
addComponent(tt); | |||
addComponent(label); | |||
} | |||
@Override | |||
public String getTestDescription() { | |||
return "Allow disabling multi selection's touch screen detection for hybrid devices"; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 11601; | |||
} | |||
} |
@@ -0,0 +1,89 @@ | |||
/* | |||
* Copyright 2000-2020 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.v7.tests.components.combobox; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.v7.data.util.BeanContainer; | |||
import com.vaadin.v7.ui.AbstractSelect.ItemCaptionMode; | |||
import com.vaadin.v7.ui.ComboBox; | |||
/** | |||
* Test for issue #11246 where ComboBox set to render from Property does not | |||
* filter correctly when page size is 0 | |||
* | |||
* @author Vaadin Ltd | |||
*/ | |||
@SuppressWarnings("deprecation") | |||
public class ComboboxPageLengthZeroFilter extends AbstractTestUI { | |||
public static class Topping { | |||
private int id; | |||
private String name; | |||
public Topping(int id, String name) { | |||
this.id = id; | |||
this.name = name; | |||
} | |||
public void setId(int id) { | |||
this.id = id; | |||
} | |||
public int getId() { | |||
return id; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
} | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
BeanContainer<Integer, Topping> container = new BeanContainer<Integer, Topping>( | |||
Topping.class); | |||
container.setBeanIdProperty("id"); | |||
for (int i = 0; i < 12; i++) { | |||
container.addBean(new Topping(i, "Topping " + i)); | |||
} | |||
final ComboBox comboBox = new ComboBox(); | |||
comboBox.setPageLength(0); | |||
comboBox.setItemCaptionMode(ItemCaptionMode.PROPERTY); | |||
comboBox.setItemCaptionPropertyId("name"); | |||
comboBox.setContainerDataSource(container); | |||
comboBox.setInvalidAllowed(false); | |||
comboBox.setNullSelectionAllowed(false); | |||
comboBox.setTextInputAllowed(true); | |||
getLayout().addComponent(comboBox); | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 11246; | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Filtering should work even when ComboBox page length is zero."; | |||
} | |||
} |
@@ -25,7 +25,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { | |||
// Chrome version does not necessarily match the desired version | |||
// because of auto updates... | |||
browserIdentifier = getExpectedUserAgentString( | |||
getDesiredCapabilities()) + "81"; | |||
getDesiredCapabilities()) + "83"; | |||
} else if (BrowserUtil.isFirefox(getDesiredCapabilities())) { | |||
browserIdentifier = getExpectedUserAgentString( | |||
getDesiredCapabilities()) + "75"; |
@@ -0,0 +1,26 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import static org.junit.Assert.assertFalse; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.elements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class ComboBoxReadOnlyPopupTest extends MultiBrowserTest { | |||
@Test | |||
public void expandedComboBoxSetToReadOnlyShouldHidePopup() { | |||
openTestURL(); | |||
ComboBoxElement comboBox = $(ComboBoxElement.class).first(); | |||
comboBox.openPopup(); | |||
// Calls comboBox.setReadOnly(true); | |||
comboBox.sendKeys(String.valueOf('q')); | |||
assertFalse("Read-only ComboBox's popup should be hidden!", | |||
comboBox.isPopupOpen()); | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
package com.vaadin.tests.components.table; | |||
import static org.junit.Assert.assertEquals; | |||
import org.junit.Test; | |||
import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.testbench.elements.TableElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
public class CtrlShiftMultiselectTouchDetectionDisabledTest | |||
extends SingleBrowserTest { | |||
@Override | |||
protected boolean requireWindowFocusForIE() { | |||
return true; | |||
} | |||
@Test | |||
public void testSelectedCount() { | |||
openTestURL(); | |||
clickRow(3); | |||
new Actions(driver).keyDown(Keys.SHIFT).perform(); | |||
clickRow(8); | |||
new Actions(driver).keyUp(Keys.SHIFT).perform(); | |||
new Actions(driver).release().perform(); | |||
LabelElement labelElement = $(LabelElement.class).id("count"); | |||
assertEquals("Unexpected amount of selected rows", "6", | |||
labelElement.getText()); | |||
} | |||
private void clickRow(int index) { | |||
TableElement tableElement = $(TableElement.class).first(); | |||
tableElement.getRow(index).click(); | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
package com.vaadin.tests.components.table; | |||
import java.util.List; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
import org.openqa.selenium.By; | |||
import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.elements.TableElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class TableScrollsOnRefreshTest extends MultiBrowserTest { | |||
@Test | |||
public void ensureNoScrolling() throws InterruptedException { | |||
openTestURL(); | |||
TableElement table = $(TableElement.class).first(); | |||
table.scroll(10000); | |||
sleep(500); // wait for both data requests | |||
String firstCellText = getFirstVisibleCell(table).getText(); | |||
ButtonElement refresh = $(ButtonElement.class).first(); | |||
refresh.click(); | |||
sleep(500); // wait for both data requests | |||
Assert.assertEquals(firstCellText, | |||
getFirstVisibleCell(table).getText()); | |||
refresh.click(); | |||
sleep(500); // wait for both data requests | |||
Assert.assertEquals(firstCellText, | |||
getFirstVisibleCell(table).getText()); | |||
} | |||
private WebElement getFirstVisibleCell(TableElement table) { | |||
int tableBodyTop = table.findElement(By.className("v-table-body")) | |||
.getLocation().getY(); | |||
List<WebElement> cells = table | |||
.findElements(By.className("v-table-cell-content")); | |||
for (WebElement cell : cells) { | |||
if (cell.getLocation().getY() > tableBodyTop) { | |||
return cell; | |||
} | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.vaadin.tests.components.treetable; | |||
import static org.junit.Assert.assertEquals; | |||
import org.junit.Test; | |||
import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.elements.LabelElement; | |||
import com.vaadin.testbench.elements.TreeTableElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
public class TreeTableMultiselectTest extends SingleBrowserTest { | |||
@Override | |||
protected boolean requireWindowFocusForIE() { | |||
return true; | |||
} | |||
@Test | |||
public void testSelectedCount() { | |||
openTestURL(); | |||
clickRow(0); | |||
new Actions(driver).keyDown(Keys.SHIFT).perform(); | |||
clickRow(2); | |||
new Actions(driver).keyUp(Keys.SHIFT).perform(); | |||
new Actions(driver).release().perform(); | |||
LabelElement labelElement = $(LabelElement.class).id("count"); | |||
assertEquals("Unexpected amount of selected rows", "3", | |||
labelElement.getText()); | |||
} | |||
private void clickRow(int index) { | |||
TreeTableElement treeTable = $(TreeTableElement.class).first(); | |||
treeTable.getRow(index).click(); | |||
} | |||
} |
@@ -0,0 +1,28 @@ | |||
package com.vaadin.v7.tests.components.combobox; | |||
import java.util.List; | |||
import org.junit.Assert; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
public class ComboboxPageLengthZeroFilterTest extends MultiBrowserTest { | |||
@Test | |||
public void testOptionsNotEmpty() { | |||
openTestURL(); | |||
List<String> suggestions = getFilterSuggestions("T"); | |||
Assert.assertEquals("All items should be presented!", 12, | |||
suggestions.size()); | |||
} | |||
private List<String> getFilterSuggestions(String string) { | |||
ComboBoxElement comboBox = $(ComboBoxElement.class).first(); | |||
comboBox.findElement(By.vaadin("#textbox")).sendKeys(string); | |||
return comboBox.getPopupSuggestions(); | |||
} | |||
} |