diff options
author | Jouni Koivuviita <jouni@vaadin.com> | 2014-11-14 12:21:26 +0200 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-11-28 12:15:29 +0200 |
commit | 826e5ec7ee80fca1068333c3360eb83442386074 (patch) | |
tree | bf93fc8e4aff2275a1bb05a86247e0d17f926c2f /uitest/src | |
parent | 95fdc0996298713000d60c94195b9446850dc819 (diff) | |
download | vaadin-framework-826e5ec7ee80fca1068333c3360eb83442386074.tar.gz vaadin-framework-826e5ec7ee80fca1068333c3360eb83442386074.zip |
Drop indicators in Valo are now working as in Reindeer theme (#14836)
Change-Id: I12014c4329ca629dbfc9226b3b70538d33442690
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java | 53 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java | 81 |
2 files changed, 134 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java new file mode 100644 index 0000000000..e3848bb152 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.annotations.Theme; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Table; + +@Theme("valo") +@SuppressWarnings("serial") +public class TableDropIndicatorValo extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + + Table table = new Table(); + + table.addContainerProperty("foo", Integer.class, 0); + table.addContainerProperty("bar", Integer.class, 0); + // table.addContainerProperty("button", Button.class, null); + + for (int i = 0; i < 40; i++) { + // Button b = new Button("testbutton"); + // b.setHeight("50px"); + table.addItem(new Object[] { i, i }, i); + } + + table.setDragMode(Table.TableDragMode.ROW); + table.setSelectable(true); + + table.setDropHandler(new DropHandler() { + @Override + public void drop(DragAndDropEvent dragAndDropEvent) { + + } + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + }); + + addComponent(table); + } + + @Override + protected String getTestDescription() { + return "Tests if the drop indicator appears between two rows as it should"; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java new file mode 100644 index 0000000000..82a66eba07 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.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.components.table; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that clicking on active fields doesn't change Table selection, nor does + * dragging rows. + * + * @author Vaadin Ltd + */ + +public class TableDropIndicatorValoTest extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + + super.setup(); + openTestURL(); + } + + @Test + public void indicator() throws Exception { + + dragRowWithoutDropping(1); + compareScreen("indicator"); + } + + private List<WebElement> getCellContents(WebElement row) { + + return row.findElements(By.className("v-table-cell-content")); + } + + private List<WebElement> getRows() { + + return getTable().findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + } + + private TableElement getTable() { + + return $(TableElement.class).first(); + } + + private void dragRowWithoutDropping(int from) { + + List<WebElement> rows = getRows(); + WebElement row = rows.get(from); + List<WebElement> cellContents = getCellContents(row); + + int rowHeight = row.getSize().getHeight(); + int halfRowHeight = (int) (rowHeight + 0.5) / 2; // rounded off + int oneAndAHalfRow = rowHeight + halfRowHeight; + + new Actions(getDriver()).moveToElement(cellContents.get(1)) + .clickAndHold().moveByOffset(0, oneAndAHalfRow).perform(); + } +}
\ No newline at end of file |