]> source.dussan.org Git - vaadin-framework.git/commitdiff
Escalator tests for columns and rows (#13334)
authorHenrik Paul <henrik@vaadin.com>
Thu, 4 Sep 2014 13:33:41 +0000 (16:33 +0300)
committerVaadin Code Review <review@vaadin.com>
Wed, 10 Sep 2014 09:19:51 +0000 (09:19 +0000)
Change-Id: I258135dce0d78baf8d8483e6b24a2510161cee12

uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorRowColumnTest.java [new file with mode: 0644]

index 745802a04f0a1126a1ecb647bcfa1b19c8bb1ae4..4593e40155edbe41e8596f406820cf500540f37b 100644 (file)
@@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue;
 
 import org.openqa.selenium.By;
 import org.openqa.selenium.Dimension;
+import org.openqa.selenium.JavascriptExecutor;
 import org.openqa.selenium.NoSuchElementException;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.interactions.Actions;
@@ -38,6 +39,12 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
     protected static final String BODY_ROWS = "Body Rows";
     protected static final String FOOTER_ROWS = "Footer Rows";
 
+    protected static final String GENERAL = "General";
+    protected static final String POPULATE_COLUMN_ROW = "Populate Escalator (columns, then rows)";
+    protected static final String POPULATE_ROW_COLUMN = "Populate Escalator (rows, then columns)";
+    protected static final String CLEAR_COLUMN_ROW = "Clear (columns, then rows)";
+    protected static final String CLEAR_ROW_COLUMN = "Clear (rows, then columns)";
+
     @Override
     protected Class<?> getUIClass() {
         return EscalatorBasicClientFeatures.class;
@@ -125,4 +132,17 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest
         assertTrue("log did not contain: " + substring,
                 log.getText().contains(substring));
     }
+
+    protected void scrollVerticallyTo(int px) {
+        executeScript("arguments[0].scrollTop = " + px, getVeticalScrollbar());
+    }
+
+    private WebElement getVeticalScrollbar() {
+        return getEscalator().findElement(
+                By.className("v-escalator-scroller-vertical"));
+    }
+
+    protected Object executeScript(String script, Object... args) {
+        return ((JavascriptExecutor) getDriver()).executeScript(script, args);
+    }
 }
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorRowColumnTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorRowColumnTest.java
new file mode 100644 (file)
index 0000000..f45eec0
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+public class EscalatorRowColumnTest extends EscalatorBasicClientFeaturesTest {
+
+    @Test
+    public void testInit() {
+        openTestURL();
+        assertNotNull(getEscalator());
+        assertNull(getHeaderRow(0));
+        assertNull(getBodyRow(0));
+        assertNull(getFooterRow(0));
+
+        assertLogContains("Columns: 0");
+        assertLogContains("Header rows: 0");
+        assertLogContains("Body rows: 0");
+        assertLogContains("Footer rows: 0");
+    }
+
+    @Test
+    public void testInsertAColumn() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        assertNull(getHeaderRow(0));
+        assertNull(getBodyRow(0));
+        assertNull(getFooterRow(0));
+        assertLogContains("Columns: 1");
+    }
+
+    @Test
+    public void testInsertAHeaderRow() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, HEADER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Header rows: 1");
+    }
+
+    @Test
+    public void testInsertABodyRow() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Body rows: 1");
+    }
+
+    @Test
+    public void testInsertAFooterRow() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, FOOTER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Footer rows: 1");
+    }
+
+    @Test
+    public void testInsertAColumnAndAHeaderRow() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        selectMenuPath(COLUMNS_AND_ROWS, HEADER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        assertNotNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Columns: 1");
+        assertLogContains("Header rows: 1");
+    }
+
+    @Test
+    public void testInsertAColumnAndABodyRow() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNotNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Columns: 1");
+        assertLogContains("Body rows: 1");
+    }
+
+    @Test
+    public void testInsertAColumnAndAFooterRow() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        selectMenuPath(COLUMNS_AND_ROWS, FOOTER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNotNull(getFooterCell(0, 0));
+        assertLogContains("Columns: 1");
+        assertLogContains("Footer rows: 1");
+    }
+
+    @Test
+    public void testInsertAHeaderRowAndAColumn() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, HEADER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        assertNotNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Columns: 1");
+        assertLogContains("Header rows: 1");
+    }
+
+    @Test
+    public void testInsertABodyRowAndAColumn() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNotNull(getBodyCell(0, 0));
+        assertNull(getFooterCell(0, 0));
+        assertLogContains("Columns: 1");
+        assertLogContains("Body rows: 1");
+    }
+
+    @Test
+    public void testInsertAFooterRowAndAColumn() {
+        openTestURL();
+
+        selectMenuPath(COLUMNS_AND_ROWS, FOOTER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
+        selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
+        assertNull(getHeaderCell(0, 0));
+        assertNull(getBodyCell(0, 0));
+        assertNotNull(getFooterCell(0, 0));
+        assertLogContains("Columns: 1");
+        assertLogContains("Footer rows: 1");
+    }
+
+    @Test
+    public void testFillColRow() {
+        openTestURL();
+
+        selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
+        scrollVerticallyTo(2000); // more like 1857, but this should be enough.
+
+        // if not found, an exception is thrown here
+        findElement(By.xpath("//td[text()='Cell: 9,99']"));
+    }
+
+    @Test
+    public void testFillRowCol() {
+        openTestURL();
+
+        selectMenuPath(GENERAL, POPULATE_ROW_COLUMN);
+        scrollVerticallyTo(2000); // more like 1857, but this should be enough.
+
+        // if not found, an exception is thrown here
+        findElement(By.xpath("//td[text()='Cell: 9,99']"));
+    }
+
+    @Test
+    public void testClearColRow() {
+        openTestURL();
+
+        selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
+        selectMenuPath(GENERAL, CLEAR_COLUMN_ROW);
+
+        assertNull(getBodyCell(0, 0));
+    }
+
+    @Test
+    public void testClearRowCol() {
+        openTestURL();
+
+        selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
+        selectMenuPath(GENERAL, CLEAR_ROW_COLUMN);
+
+        assertNull(getBodyCell(0, 0));
+    }
+}