]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed Grid details row height regression and refactored tests (#17423)
authorPekka Hyvönen <pekka@vaadin.com>
Thu, 23 Apr 2015 11:29:25 +0000 (14:29 +0300)
committerPekka Hyvönen <pekka@vaadin.com>
Mon, 27 Apr 2015 06:53:08 +0000 (06:53 +0000)
Fixed regression caused by initial #17423 change
Refactored tests for Grid's details row and added @TestCategory("grid").

Change-Id: I0b68eb7d6650d16700104f76b00972483d615855

client/src/com/vaadin/client/widgets/Grid.java
uitest/src/com/vaadin/tests/components/grid/GridDetailsLocation.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/grid/GridDetailsLocationTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/grid/GridScrollToRowWithDetails.java [deleted file]
uitest/src/com/vaadin/tests/components/grid/GridScrollToRowWithDetailsTest.java [deleted file]

index 005532a84943b90ea10335a4898d81f11df8aa60..08a86fe6a75f8a9c1a3d5332da5031bf373de48e 100644 (file)
@@ -2901,7 +2901,7 @@ public class Grid<T> extends ResizeComposite implements
                  * re-measure it to make sure that it's the correct height.
                  */
                 double measuredHeight = WidgetUtil
-                        .getRequiredHeightBoundingClientRectDouble(spacerElement);
+                        .getRequiredHeightBoundingClientRectDouble(element);
                 assert getElement().isOrHasChild(spacerElement) : "The spacer element wasn't in the DOM during measurement, but was assumed to be.";
                 spacerHeight = measuredHeight;
             }
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsLocation.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsLocation.java
new file mode 100644 (file)
index 0000000..2880df4
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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.Theme;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.util.Person;
+import com.vaadin.tests.util.PersonContainer;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.DetailsGenerator;
+import com.vaadin.ui.Grid.RowReference;
+import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.ValoTheme;
+
+@Theme(ValoTheme.THEME_NAME)
+public class GridDetailsLocation extends UI {
+
+    private final DetailsGenerator detailsGenerator = new DetailsGenerator() {
+        @Override
+        public Component getDetails(RowReference rowReference) {
+            Person person = (Person) rowReference.getItemId();
+            Label label = new Label(person.getFirstName() + " "
+                    + person.getLastName());
+            // currently the decorator row doesn't change its height when the
+            // content height is different.
+            label.setHeight("30px");
+            return label;
+        }
+    };
+
+    private TextField numberTextField;
+    private Grid grid;
+
+    @Override
+    protected void init(VaadinRequest request) {
+
+        Layout layout = new VerticalLayout();
+
+        grid = new Grid(PersonContainer.createWithTestData(1000));
+        grid.setSelectionMode(SelectionMode.NONE);
+        layout.addComponent(grid);
+
+        final CheckBox checkbox = new CheckBox("Details generator");
+        checkbox.addValueChangeListener(new ValueChangeListener() {
+            @Override
+            @SuppressWarnings("boxing")
+            public void valueChange(ValueChangeEvent event) {
+                if (checkbox.getValue()) {
+                    grid.setDetailsGenerator(detailsGenerator);
+                } else {
+                    grid.setDetailsGenerator(DetailsGenerator.NULL);
+                }
+            }
+        });
+        layout.addComponent(checkbox);
+
+        numberTextField = new TextField("Row");
+        numberTextField.setImmediate(true);
+        layout.addComponent(numberTextField);
+
+        layout.addComponent(new Button("Toggle and scroll",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        toggle();
+                        scrollTo();
+                    }
+                }));
+        layout.addComponent(new Button("Scroll and toggle",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        scrollTo();
+                        toggle();
+                    }
+                }));
+
+        setContent(layout);
+    }
+
+    private void toggle() {
+        Object itemId = getItemId();
+        boolean isVisible = grid.isDetailsVisible(itemId);
+        grid.setDetailsVisible(itemId, !isVisible);
+    }
+
+    private void scrollTo() {
+        grid.scrollTo(getItemId());
+    }
+
+    private Object getItemId() {
+        int row = Integer.parseInt(numberTextField.getValue());
+        Object itemId = grid.getContainerDataSource().getIdByIndex(row);
+        return itemId;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsLocationTest.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsLocationTest.java
new file mode 100644 (file)
index 0000000..06e79ac
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.StaleElementReferenceException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elements.GridElement.GridRowElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.components.grid.basicfeatures.element.CustomGridElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridDetailsLocationTest extends MultiBrowserTest {
+
+    private static final int decoratorDefaultHeight = 50;
+    private static final int decoratorDefinedHeight = 30;
+
+    private static class Param {
+        private final int rowIndex;
+        private final boolean useGenerator;
+        private final boolean scrollFirstToBottom;
+
+        public Param(int rowIndex, boolean useGenerator,
+                boolean scrollFirstToBottom) {
+            this.rowIndex = rowIndex;
+            this.useGenerator = useGenerator;
+            this.scrollFirstToBottom = scrollFirstToBottom;
+        }
+
+        public int getRowIndex() {
+            return rowIndex;
+        }
+
+        public boolean useGenerator() {
+            return useGenerator;
+        }
+
+        public boolean scrollFirstToBottom() {
+            return scrollFirstToBottom;
+        }
+
+        @Override
+        public String toString() {
+            return "Param [rowIndex=" + getRowIndex() + ", useGenerator="
+                    + useGenerator() + ", scrollFirstToBottom="
+                    + scrollFirstToBottom() + "]";
+        }
+
+    }
+
+    public static Collection<Param> parameters() {
+        List<Param> data = new ArrayList<Param>();
+
+        int[][] params = new int[][] {// @formatter:off
+            // row, top+noGen, top+gen
+            { 0, decoratorDefaultHeight, decoratorDefinedHeight }, 
+            { 500, decoratorDefaultHeight, decoratorDefinedHeight },
+            { 999, decoratorDefaultHeight, decoratorDefinedHeight},
+        };
+        // @formatter:on
+
+        for (int i[] : params) {
+            int rowIndex = i[0];
+
+            data.add(new Param(rowIndex, false, false));
+            data.add(new Param(rowIndex, true, false));
+            data.add(new Param(rowIndex, false, true));
+            data.add(new Param(rowIndex, true, true));
+        }
+
+        return data;
+    }
+
+    @Before
+    public void setUp() {
+        setDebug(true);
+    }
+
+    @Test
+    public void toggleAndScroll() throws Throwable {
+        for (Param param : parameters()) {
+            try {
+                openTestURL();
+                useGenerator(param.useGenerator());
+                scrollToBottom(param.scrollFirstToBottom());
+
+                // the tested method
+                toggleAndScroll(param.getRowIndex());
+
+                verifyLocation(param);
+            } catch (Throwable t) {
+                throw new Throwable("" + param, t);
+            }
+        }
+    }
+
+    @Test
+    public void scrollAndToggle() throws Throwable {
+        for (Param param : parameters()) {
+            try {
+                openTestURL();
+                useGenerator(param.useGenerator());
+                scrollToBottom(param.scrollFirstToBottom());
+
+                // the tested method
+                scrollAndToggle(param.getRowIndex());
+
+                verifyLocation(param);
+
+            } catch (Throwable t) {
+                throw new Throwable("" + param, t);
+            }
+        }
+    }
+
+    @Test
+    public void testDecoratorHeightWithNoGenerator() {
+        openTestURL();
+        toggleAndScroll(5);
+
+        verifyDetailsRowHeight(5, decoratorDefaultHeight);
+    }
+
+    @Test
+    public void testDecoratorHeightWithGenerator() {
+        openTestURL();
+        useGenerator(true);
+        toggleAndScroll(5);
+
+        verifyDetailsRowHeight(5, decoratorDefinedHeight);
+    }
+
+    private void verifyDetailsRowHeight(int rowIndex, int expectedHeight) {
+        waitForDetailsVisible();
+        WebElement details = getDetailsElement();
+        Assert.assertEquals("Wrong details row height", expectedHeight, details
+                .getSize().getHeight());
+    }
+
+    private void verifyLocation(Param param) {
+        Assert.assertFalse("Notification was present",
+                isElementPresent(By.className("v-Notification")));
+
+        TestBenchElement headerRow = getGrid().getHeaderRow(0);
+        final int topBoundary = headerRow.getLocation().getX()
+                + headerRow.getSize().height;
+        final int bottomBoundary = getGrid().getLocation().getX()
+                + getGrid().getSize().getHeight()
+                - getHorizontalScrollbar().getSize().height;
+
+        GridRowElement row = getGrid().getRow(param.getRowIndex());
+        final int rowTop = row.getLocation().getX();
+
+        waitForDetailsVisible();
+        WebElement details = getDetailsElement();
+        final int detailsBottom = details.getLocation().getX()
+                + details.getSize().getHeight();
+
+        assertGreaterOrEqual("Row top should be inside grid, gridTop:"
+                + topBoundary + " rowTop" + rowTop, topBoundary, rowTop);
+        assertLessThanOrEqual(
+                "Decorator bottom should be inside grid, gridBottom:"
+                        + bottomBoundary + " decoratorBotton:" + detailsBottom,
+                detailsBottom, bottomBoundary);
+
+        Assert.assertFalse("Notification was present",
+                isElementPresent(By.className("v-Notification")));
+    }
+
+    private final By locator = By.className("v-grid-spacer");
+
+    private WebElement getDetailsElement() {
+        return findElement(locator);
+    }
+
+    private void waitForDetailsVisible() {
+        waitUntil(new ExpectedCondition<WebElement>() {
+
+            @Override
+            public WebElement apply(WebDriver driver) {
+                try {
+                    WebElement detailsElement = getDetailsElement();
+                    return detailsElement.isDisplayed()
+                            && detailsElement.getSize().getHeight() > 3 ? detailsElement
+                            : null;
+                } catch (StaleElementReferenceException e) {
+                    return null;
+                }
+            }
+
+            @Override
+            public String toString() {
+                return "visibility of element located by " + locator;
+            }
+
+        }, 5);
+        waitForElementVisible(By.className("v-grid-spacer"));
+    }
+
+    private void scrollToBottom(boolean scrollFirstToBottom) {
+        if (scrollFirstToBottom) {
+            executeScript("arguments[0].scrollTop = 9999999",
+                    getVerticalScrollbar());
+        }
+    }
+
+    private void useGenerator(boolean use) {
+        CheckBoxElement checkBox = $(CheckBoxElement.class).first();
+        boolean isChecked = isCheckedValo(checkBox);
+        if (use != isChecked) {
+            clickValo(checkBox);
+        }
+    }
+
+    @SuppressWarnings("boxing")
+    private boolean isCheckedValo(CheckBoxElement checkBoxElement) {
+        WebElement checkbox = checkBoxElement.findElement(By.tagName("input"));
+        Object value = executeScript("return arguments[0].checked;", checkbox);
+        return (Boolean) value;
+    }
+
+    private void clickValo(CheckBoxElement checkBoxElement) {
+        checkBoxElement.findElement(By.tagName("label")).click();
+    }
+
+    private Object executeScript(String string, Object... param) {
+        return ((JavascriptExecutor) getDriver()).executeScript(string, param);
+    }
+
+    private void scrollAndToggle(int row) {
+        setRow(row);
+        getScrollAndToggle().click();
+    }
+
+    private void toggleAndScroll(int row) {
+        setRow(row);
+        getToggleAndScroll().click();
+    }
+
+    private ButtonElement getScrollAndToggle() {
+        return $(ButtonElement.class).caption("Scroll and toggle").first();
+    }
+
+    private ButtonElement getToggleAndScroll() {
+        return $(ButtonElement.class).caption("Toggle and scroll").first();
+    }
+
+    private void setRow(int row) {
+        $(TextFieldElement.class).first().clear();
+        $(TextFieldElement.class).first().sendKeys(String.valueOf(row),
+                Keys.ENTER, Keys.TAB);
+    }
+
+    private CustomGridElement getGrid() {
+        return $(CustomGridElement.class).first();
+    }
+
+    private WebElement getVerticalScrollbar() {
+        WebElement scrollBar = getGrid().findElement(
+                By.className("v-grid-scroller-vertical"));
+        return scrollBar;
+    }
+
+    private WebElement getHorizontalScrollbar() {
+        WebElement scrollBar = getGrid().findElement(
+                By.className("v-grid-scroller-horizontal"));
+        return scrollBar;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridScrollToRowWithDetails.java b/uitest/src/com/vaadin/tests/components/grid/GridScrollToRowWithDetails.java
deleted file mode 100644 (file)
index 5659f01..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.Theme;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.util.Person;
-import com.vaadin.tests.util.PersonContainer;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Grid;
-import com.vaadin.ui.Grid.DetailsGenerator;
-import com.vaadin.ui.Grid.RowReference;
-import com.vaadin.ui.Grid.SelectionMode;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.TextField;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.themes.ValoTheme;
-
-@Theme(ValoTheme.THEME_NAME)
-public class GridScrollToRowWithDetails extends UI {
-
-    private final DetailsGenerator detailsGenerator = new DetailsGenerator() {
-        @Override
-        public Component getDetails(RowReference rowReference) {
-            Person person = (Person) rowReference.getItemId();
-            Label label = new Label(person.getFirstName() + " "
-                    + person.getLastName());
-            label.setHeight("30px");
-            return label;
-        }
-    };
-
-    private TextField numberTextField;
-    private Grid grid;
-
-    @Override
-    protected void init(VaadinRequest request) {
-
-        Layout layout = new VerticalLayout();
-
-        grid = new Grid(PersonContainer.createWithTestData(1000));
-        grid.setSelectionMode(SelectionMode.NONE);
-        layout.addComponent(grid);
-
-        final CheckBox checkbox = new CheckBox("Details generator");
-        checkbox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            @SuppressWarnings("boxing")
-            public void valueChange(ValueChangeEvent event) {
-                if (checkbox.getValue()) {
-                    grid.setDetailsGenerator(detailsGenerator);
-                } else {
-                    grid.setDetailsGenerator(DetailsGenerator.NULL);
-                }
-            }
-        });
-        layout.addComponent(checkbox);
-
-        numberTextField = new TextField("Row");
-        numberTextField.setImmediate(false);
-        layout.addComponent(numberTextField);
-
-        layout.addComponent(new Button("Toggle", new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                toggle();
-            }
-        }));
-
-        layout.addComponent(new Button("Scroll to", new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                scrollTo();
-            }
-        }));
-
-        layout.addComponent(new Button("Toggle and scroll",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        toggle();
-                        scrollTo();
-                    }
-                }));
-        layout.addComponent(new Button("Scroll and toggle",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        scrollTo();
-                        toggle();
-                    }
-                }));
-
-        setContent(layout);
-    }
-
-    private void toggle() {
-        Object itemId = getItemId();
-        boolean isVisible = grid.isDetailsVisible(itemId);
-        grid.setDetailsVisible(itemId, !isVisible);
-    }
-
-    private void scrollTo() {
-        grid.scrollTo(getItemId());
-    }
-
-    private Object getItemId() {
-        int row = Integer.parseInt(numberTextField.getValue());
-        Object itemId = grid.getContainerDataSource().getIdByIndex(row);
-        return itemId;
-    }
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridScrollToRowWithDetailsTest.java b/uitest/src/com/vaadin/tests/components/grid/GridScrollToRowWithDetailsTest.java
deleted file mode 100644 (file)
index b6ecd3f..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * 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.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.shared.ui.grid.Range;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.CheckBoxElement;
-import com.vaadin.testbench.elements.TextFieldElement;
-import com.vaadin.tests.components.grid.basicfeatures.element.CustomGridElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class GridScrollToRowWithDetailsTest extends MultiBrowserTest {
-
-    private static class Param {
-        private final int rowIndex;
-        private final boolean useGenerator;
-        private final boolean scrollFirstToBottom;
-        private final int scrollTarget;
-
-        public Param(int rowIndex, boolean useGenerator,
-                boolean scrollFirstToBottom, int scrollTarget) {
-            this.rowIndex = rowIndex;
-            this.useGenerator = useGenerator;
-            this.scrollFirstToBottom = scrollFirstToBottom;
-            this.scrollTarget = Math.max(0, scrollTarget);
-        }
-
-        public int getRowIndex() {
-            return rowIndex;
-        }
-
-        public boolean useGenerator() {
-            return useGenerator;
-        }
-
-        public boolean scrollFirstToBottom() {
-            return scrollFirstToBottom;
-        }
-
-        public int getScrollTarget() {
-            return scrollTarget;
-        }
-
-        @Override
-        public String toString() {
-            return "Param [rowIndex=" + getRowIndex() + ", useGenerator="
-                    + useGenerator() + ", scrollFirstToBottom="
-                    + scrollFirstToBottom() + ", scrollTarget="
-                    + getScrollTarget() + "]";
-        }
-    }
-
-    public static Collection<Param> parameters() {
-        List<Param> data = new ArrayList<Param>();
-
-        int[][] params = new int[][] {// @formatter:off
-            // row, top+noGen, top+gen, bot+noGen, bot+gen
-            { 0, 0, 0, 0, 0 }, 
-            { 500, 18741, 18723, 19000, 19000 },
-            { 999, 37703, 37685, 37703, 37685 },
-        };
-        // @formatter:on
-
-        for (int i[] : params) {
-            int rowIndex = i[0];
-            int targetTopScrollWithoutGenerator = i[1];
-            int targetTopScrollWithGenerator = i[2];
-            int targetBottomScrollWithoutGenerator = i[3];
-            int targetBottomScrollWithGenerator = i[4];
-
-            data.add(new Param(rowIndex, false, false,
-                    targetTopScrollWithoutGenerator));
-            data.add(new Param(rowIndex, true, false,
-                    targetTopScrollWithGenerator));
-            data.add(new Param(rowIndex, false, true,
-                    targetBottomScrollWithoutGenerator));
-            data.add(new Param(rowIndex, true, true,
-                    targetBottomScrollWithGenerator));
-        }
-
-        return data;
-    }
-
-    @Before
-    public void setUp() {
-        setDebug(true);
-    }
-
-    @Test
-    public void toggleAndScroll() throws Throwable {
-        for (Param param : parameters()) {
-            try {
-                openTestURL();
-                useGenerator(param.useGenerator());
-                scrollToBottom(param.scrollFirstToBottom());
-
-                // the tested method
-                toggleAndScroll(param.getRowIndex());
-
-                Range allowedRange = Range.withLength(
-                        param.getScrollTarget() - 5, 10);
-                assertTrue(
-                        allowedRange + " does not contain " + getScrollTop(),
-                        allowedRange.contains(getScrollTop()));
-            } catch (Throwable t) {
-                throw new Throwable("" + param, t);
-            }
-        }
-    }
-
-    @Test
-    public void scrollAndToggle() throws Throwable {
-        for (Param param : parameters()) {
-            try {
-                openTestURL();
-                useGenerator(param.useGenerator());
-                scrollToBottom(param.scrollFirstToBottom());
-
-                // the tested method
-                scrollAndToggle(param.getRowIndex());
-
-                Range allowedRange = Range.withLength(
-                        param.getScrollTarget() - 5, 10);
-                assertTrue(
-                        allowedRange + " does not contain " + getScrollTop(),
-                        allowedRange.contains(getScrollTop()));
-            } catch (Throwable t) {
-                throw new Throwable("" + param, t);
-            }
-        }
-    }
-
-    private void scrollToBottom(boolean scrollFirstToBottom) {
-        if (scrollFirstToBottom) {
-            executeScript("arguments[0].scrollTop = 9999999",
-                    getVerticalScrollbar());
-        }
-    }
-
-    private void useGenerator(boolean use) {
-        CheckBoxElement checkBox = $(CheckBoxElement.class).first();
-        boolean isChecked = isCheckedValo(checkBox);
-        if (use != isChecked) {
-            clickValo(checkBox);
-        }
-    }
-
-    @SuppressWarnings("boxing")
-    private boolean isCheckedValo(CheckBoxElement checkBoxElement) {
-        WebElement checkbox = checkBoxElement.findElement(By.tagName("input"));
-        Object value = executeScript("return arguments[0].checked;", checkbox);
-        return (Boolean) value;
-    }
-
-    private void clickValo(CheckBoxElement checkBoxElement) {
-        checkBoxElement.findElement(By.tagName("label")).click();
-    }
-
-    private Object executeScript(String string, Object... param) {
-        return ((JavascriptExecutor) getDriver()).executeScript(string, param);
-    }
-
-    private void scrollAndToggle(int row) {
-        setRow(row);
-        getScrollAndToggle().click();
-    }
-
-    private void toggleAndScroll(int row) {
-        setRow(row);
-        getToggleAndScroll().click();
-    }
-
-    private ButtonElement getScrollAndToggle() {
-        return $(ButtonElement.class).caption("Scroll and toggle").first();
-    }
-
-    private ButtonElement getToggleAndScroll() {
-        return $(ButtonElement.class).caption("Toggle and scroll").first();
-    }
-
-    private void setRow(int row) {
-        $(TextFieldElement.class).first().setValue(String.valueOf(row));
-    }
-
-    private CustomGridElement getGrid() {
-        return $(CustomGridElement.class).first();
-    }
-
-    private int getScrollTop() {
-        return ((Long) executeScript("return arguments[0].scrollTop;",
-                getVerticalScrollbar())).intValue();
-    }
-
-    private WebElement getVerticalScrollbar() {
-        WebElement scrollBar = getGrid().findElement(
-                By.className("v-grid-scroller-vertical"));
-        return scrollBar;
-    }
-}