aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests')
-rw-r--r--uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java57
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnector.java24
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnectorTest.java21
-rw-r--r--uitest/src/com/vaadin/tests/components/embedded/FlashIsVisibleTest.java32
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSize.java34
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSizeTest.java57
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java22
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java57
-rw-r--r--uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java30
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java114
10 files changed, 369 insertions, 79 deletions
diff --git a/uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java b/uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java
deleted file mode 100644
index 1a3b4cdda5..0000000000
--- a/uitest/src/com/vaadin/tests/components/TouchDevicesTooltip.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.vaadin.tests.components;
-
-import com.vaadin.data.util.converter.StringToIntegerConverter;
-import com.vaadin.data.validator.IntegerRangeValidator;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.TextField;
-
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-
-public class TouchDevicesTooltip extends AbstractTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- final Label errorLabel = new Label("No error");
- addComponent(errorLabel);
-
- TextField textField = new TextField("Value");
- textField.setConverter(new StringToIntegerConverter());
- textField.addValidator(new IntegerRangeValidator("incorrect value", 0, 100));
- textField.setImmediate(true);
- textField.setValue("-5");
- addComponent(textField);
-
- TextField textField2 = new TextField("Value2");
- textField2.setConverter(new StringToIntegerConverter());
- textField2.addValidator(new IntegerRangeValidator("incorrect value2", 0, 100));
- textField2.setImmediate(true);
- textField2.setValue("-5");
- addComponent(textField2);
- }
-
- public static class Bean {
- @NotNull
- @Min(0)
- private Integer value;
-
- public Integer getValue() {
- return value;
- }
-
- public void setValue(Integer value) {
- this.value = value;
- }
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 15353;
- }
-
- @Override
- public String getDescription() {
- return "Displaying error message in slot for touch devices";
- }
-}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnector.java b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnector.java
new file mode 100644
index 0000000000..5cdc8f1396
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnector.java
@@ -0,0 +1,24 @@
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.PopupDateField;
+
+public class PopupDateFieldConnector extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new PopupDateField());
+ addComponent(new DateField());
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 17090;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "PopupDateFieldElement should be accessible using TB4 PopupDateFieldElement.";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnectorTest.java b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnectorTest.java
new file mode 100644
index 0000000000..5334327a83
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldConnectorTest.java
@@ -0,0 +1,21 @@
+package com.vaadin.tests.components.datefield;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+import com.vaadin.testbench.elements.PopupDateFieldElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class PopupDateFieldConnectorTest extends SingleBrowserTest {
+
+ @Test
+ public void popupDateFieldElementIsLocated() {
+ openTestURL();
+
+ assertThat($(PopupDateFieldElement.class).all().size(), is(1));
+ assertThat($(DateFieldElement.class).all().size(), is(2));
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/embedded/FlashIsVisibleTest.java b/uitest/src/com/vaadin/tests/components/embedded/FlashIsVisibleTest.java
new file mode 100644
index 0000000000..64d70df88f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/embedded/FlashIsVisibleTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.embedded;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class FlashIsVisibleTest extends
+ com.vaadin.tests.components.flash.FlashIsVisibleTest {
+
+ @Override
+ @Test
+ public void testFlashIsCorrectlyDisplayed() throws Exception {
+ assertTrue("Test is using wrong url",
+ getTestUrl().contains(".embedded."));
+ super.testFlashIsCorrectlyDisplayed();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSize.java b/uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSize.java
new file mode 100644
index 0000000000..c0e3c9d683
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSize.java
@@ -0,0 +1,34 @@
+/*
+ * 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.grid;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.widgetset.client.grid.GridCellFocusOnResetSizeWidget;
+import com.vaadin.tests.widgetset.server.TestWidgetComponent;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class GridCellFocusOnResetSize extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new TestWidgetComponent(
+ GridCellFocusOnResetSizeWidget.class));
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSizeTest.java b/uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSizeTest.java
new file mode 100644
index 0000000000..31ccb4eaf2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridCellFocusOnResetSizeTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.grid;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.elementsbase.ServerClass;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GridCellFocusOnResetSizeTest extends MultiBrowserTest {
+
+ @ServerClass("com.vaadin.tests.widgetset.server.TestWidgetComponent")
+ public static class MyGridElement extends GridElement {
+ }
+
+ @Test
+ public void testCellFocusOnSizeReset() throws IOException {
+ openTestURL();
+
+ GridElement grid = $(MyGridElement.class).first();
+ int rowIndex = 9;
+ grid.getCell(rowIndex, 0).click();
+ assertTrue("Row was not focused after click.", grid.getRow(rowIndex)
+ .isFocused());
+
+ // Clicking the button decreases size until it is down to 5 rows.
+ while (rowIndex > 4) {
+ findElement(By.tagName("button")).click();
+ assertTrue("Row focus was not moved when size decreased", grid
+ .getRow(--rowIndex).isFocused());
+ }
+
+ // Next click increases size back to 10, this should not move focus.
+ findElement(By.tagName("button")).click();
+ assertTrue("Row focus should not have moved when size increased", grid
+ .getRow(4).isFocused());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java
index 0f04a1552e..f91f93c5d5 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java
@@ -16,7 +16,6 @@
package com.vaadin.tests.components.grid.basicfeatures.server;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
import com.vaadin.testbench.elements.NotificationElement;
@@ -39,27 +38,6 @@ public class GridRowAddRemoveTest extends GridBasicFeaturesTest {
}
@Test
- @Ignore("This test checks the parameters passed to Container. Has nothing to do with what's sent to client.")
- public void removeRows_loadAllAtOnce() {
- openTestURL();
-
- selectMenuPath("Component", "Size", "HeightMode Row");
- selectMenuPath("Settings", "Clear log");
- selectMenuPath("Component", "Body rows", "Remove 18 first rows");
-
- Assert.assertTrue(
- "All newly required rows should be fetched in the same round trip.",
- logContainsText("Requested items 37 - 55"));
-
- selectMenuPath("Settings", "Clear log");
- selectMenuPath("Component", "Body rows", "Remove 18 first rows");
-
- Assert.assertTrue(
- "All newly required rows should be fetched in the same round trip.",
- logContainsText("Requested items 37 - 55"));
- }
-
- @Test
public void testAdd18Rows() {
setDebug(true);
openTestURL();
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java
new file mode 100644
index 0000000000..9313b40770
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridScrollTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.grid.basicfeatures.server;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+
+public class GridScrollTest extends GridBasicFeaturesTest {
+
+ @Test
+ public void testCorrectItemRequestsOnScroll() {
+ openTestURL();
+
+ assertTrue("Initial push from server not found",
+ getLogRow(1).equals("0. Requested items 0 - 40"));
+ // Client response varies a bit between browsers as different amount of
+ // rows is cached.
+ assertTrue("First row request from client not found", getLogRow(0)
+ .startsWith("1. Requested items 0 - "));
+
+ selectMenuPath("Component", "Size", "HeightMode Row");
+
+ selectMenuPath("Settings", "Clear log");
+ $(GridElement.class).first().scrollToRow(40);
+ assertEquals("Log row did not contain expected item request",
+ "0. Requested items 0 - 86", getLogRow(0));
+ assertEquals("There should be only one log row", " ", getLogRow(1));
+ selectMenuPath("Settings", "Clear log");
+ $(GridElement.class).first().scrollToRow(100);
+ assertEquals("Log row did not contain expected item request",
+ "0. Requested items 47 - 146", getLogRow(0));
+ assertEquals("There should be only one log row", " ", getLogRow(1));
+ selectMenuPath("Settings", "Clear log");
+ $(GridElement.class).first().scrollToRow(300);
+ assertEquals("Log row did not contain expected item request",
+ "0. Requested items 247 - 346", getLogRow(0));
+ assertEquals("There should be only one log row", " ", getLogRow(1));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
index 8f8e446ce3..d0134a4feb 100644
--- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
+++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
@@ -25,8 +25,11 @@ import java.net.SocketException;
import java.util.Enumeration;
import java.util.Properties;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
import com.vaadin.testbench.annotations.BrowserFactory;
import com.vaadin.testbench.annotations.RunOnHub;
+import com.vaadin.testbench.parallel.Browser;
/**
* Provides values for parameters which depend on where the test is run.
@@ -50,16 +53,43 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
private static final Properties properties = new Properties();
private static final File propertiesFile = new File("work",
"eclipse-run-selected-test.properties");
+ private static final String FIREFOX_PATH = "firefox.path";
+
static {
if (propertiesFile.exists()) {
try {
properties.load(new FileInputStream(propertiesFile));
+ if (properties.containsKey(RUN_LOCALLY_PROPERTY)) {
+ System.setProperty("useLocalWebDriver", "true");
+ DesiredCapabilities localBrowser = getRunLocallyCapabilities();
+ System.setProperty(
+ "browsers.include",
+ localBrowser.getBrowserName()
+ + localBrowser.getVersion());
+ }
+ if (properties.containsKey(FIREFOX_PATH)) {
+ System.setProperty(FIREFOX_PATH,
+ properties.getProperty(FIREFOX_PATH));
+ }
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
+ private static DesiredCapabilities getRunLocallyCapabilities() {
+ Browser localBrowser;
+ try {
+ localBrowser = Browser.valueOf(properties.getProperty(
+ RUN_LOCALLY_PROPERTY).toUpperCase());
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ System.err.println("Falling back to FireFox");
+ localBrowser = Browser.FIREFOX;
+ }
+ return localBrowser.getDesiredCapabilities();
+ }
+
protected static String getProperty(String name) {
String property = properties.getProperty(name);
if (property == null) {
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java
new file mode 100644
index 0000000000..b2893463a7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridCellFocusOnResetSizeWidget.java
@@ -0,0 +1,114 @@
+/*
+ * 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.widgetset.client.grid;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Button;
+import com.vaadin.client.data.DataChangeHandler;
+import com.vaadin.client.data.DataSource;
+import com.vaadin.client.renderers.HtmlRenderer;
+import com.vaadin.client.widgets.Grid;
+import com.vaadin.client.widgets.Grid.SelectionMode;
+
+public class GridCellFocusOnResetSizeWidget extends
+ PureGWTTestApplication<Grid<String[]>> {
+
+ private Grid<String[]> grid;
+
+ private final class MyDataSource implements DataSource<String[]> {
+ List<String[]> rows = new ArrayList<String[]>();
+ int ROWS_MAX = 10;
+ int size = ROWS_MAX;
+ DataChangeHandler handler = null;
+ {
+ for (int i = 0; i < ROWS_MAX; ++i) {
+ rows.add(new String[] { "Foo " + i });
+ }
+ }
+
+ @Override
+ public void ensureAvailability(int firstRowIndex, int numberOfRows) {
+ handler.dataAvailable(firstRowIndex, numberOfRows);
+ }
+
+ @Override
+ public int size() {
+ return size;
+ }
+
+ @Override
+ public void setDataChangeHandler(DataChangeHandler dataChangeHandler) {
+ handler = dataChangeHandler;
+ }
+
+ @Override
+ public RowHandle<String[]> getHandle(final String[] rowData) {
+ return null;
+ }
+
+ @Override
+ public String[] getRow(int rowIndex) {
+ if (rowIndex < size && rowIndex >= 0) {
+ return rows.get(rowIndex);
+ }
+ return null;
+ }
+
+ public void changeSize() {
+ size--;
+ if (size < ROWS_MAX / 2) {
+ size = ROWS_MAX;
+ }
+ handler.resetDataAndSize(size);
+ }
+ }
+
+ private class Col extends Grid.Column<String, String[]> {
+ public Col(String header) {
+ super(header, new HtmlRenderer());
+ }
+
+ @Override
+ public String getValue(String[] row) {
+ int index = grid.getColumns().indexOf(this);
+ return "<span>" + String.valueOf(row[index]) + "</span>";
+ }
+ }
+
+ public GridCellFocusOnResetSizeWidget() {
+ super(new Grid<String[]>());
+ grid = getTestedWidget();
+ grid.setSelectionMode(SelectionMode.NONE);
+ grid.setWidth("300px");
+ grid.addColumn(new Col("Foo"));
+ final MyDataSource dataSource = new MyDataSource();
+ grid.setDataSource(dataSource);
+ Button widget = new Button("Change Container Size");
+ widget.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ dataSource.changeSize();
+ }
+ });
+ addNorth(grid, 400);
+ addNorth(widget, 50);
+ }
+}