summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-04-13 10:25:20 +0300
committerAleksi Hietanen <aleksi@vaadin.com>2017-04-13 10:25:20 +0300
commit4454e6bdc13dec8198c9e5e95557fcf59f9f97e4 (patch)
treee9a37b2b92e709e7f4404ab3eb65d4974e9481df /uitest
parent60a6e0282e8e013acb56821f30573c65f1a6c36d (diff)
downloadvaadin-framework-4454e6bdc13dec8198c9e5e95557fcf59f9f97e4.tar.gz
vaadin-framework-4454e6bdc13dec8198c9e5e95557fcf59f9f97e4.zip
Provide GridLayout size and cell elements to JS and TB (#9019)
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/elements/gridlayout/GridLayoutUI.java44
-rw-r--r--uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java72
2 files changed, 116 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/elements/gridlayout/GridLayoutUI.java b/uitest/src/main/java/com/vaadin/tests/elements/gridlayout/GridLayoutUI.java
new file mode 100644
index 0000000000..698a64f747
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/elements/gridlayout/GridLayoutUI.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2016 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.elements.gridlayout;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.Label;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class GridLayoutUI extends AbstractTestUI {
+
+ public static final String ONE_ROW_ONE_COL = "oneRowOneCol";
+ public static final String TEN_ROWS_TEN_COLS = "tenRowsTenCols";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ GridLayout oneRowZeroCols = new GridLayout(1, 1);
+ oneRowZeroCols.setId(ONE_ROW_ONE_COL);
+ addComponent(oneRowZeroCols);
+
+ GridLayout tenTimesTen = new GridLayout(10, 10);
+ tenTimesTen.addComponent(new Label("5-5"), 5, 5);
+ tenTimesTen.addComponent(new Button("7-7 8-8"), 7, 7, 8, 8);
+ tenTimesTen.setId(TEN_ROWS_TEN_COLS);
+ addComponent(tenTimesTen);
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java
new file mode 100644
index 0000000000..78d1fe8deb
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2000-2016 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.elements.gridlayout;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class GridLayoutUITest extends SingleBrowserTest {
+
+ @Test
+ public void getRows() {
+ openTestURL();
+ Assert.assertEquals(1, $(GridLayoutElement.class)
+ .id(GridLayoutUI.ONE_ROW_ONE_COL).getRowCount());
+ Assert.assertEquals(10, $(GridLayoutElement.class)
+ .id(GridLayoutUI.TEN_ROWS_TEN_COLS).getRowCount());
+ }
+
+ @Test
+ public void getColumns() {
+ openTestURL();
+ Assert.assertEquals(1, $(GridLayoutElement.class)
+ .id(GridLayoutUI.ONE_ROW_ONE_COL).getColumnCount());
+ Assert.assertEquals(10, $(GridLayoutElement.class)
+ .id(GridLayoutUI.TEN_ROWS_TEN_COLS).getColumnCount());
+ }
+
+ @Test
+ public void getCell() {
+ openTestURL();
+ GridLayoutElement grid = $(GridLayoutElement.class)
+ .id(GridLayoutUI.TEN_ROWS_TEN_COLS);
+
+ WebElement cell55 = grid.getCell(5, 5);
+ Assert.assertEquals("v-gridlayout-slot", cell55.getAttribute("class"));
+ Assert.assertEquals("5-5", cell55.getText());
+
+ try {
+ grid.getCell(4, 4);
+ Assert.fail("Should throw for empty cell");
+ } catch (NoSuchElementException e) {
+ }
+
+ WebElement cell77 = grid.getCell(7, 7);
+ Assert.assertEquals("v-gridlayout-slot", cell77.getAttribute("class"));
+ Assert.assertEquals("7-7 8-8", cell77.getText());
+
+ try {
+ grid.getCell(7, 8);
+ Assert.fail("Should throw for merged cell");
+ } catch (NoSuchElementException e) {
+ }
+ }
+}