2 * Copyright 2000-2016 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.tests.components.grid.basicfeatures.escalator;
18 import static org.junit.Assert.assertEquals;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.WebElement;
25 import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
27 @SuppressWarnings("all")
28 public class EscalatorScrollTest extends EscalatorBasicClientFeaturesTest {
37 * Before the fix, removing and adding rows and also scrolling would put the
38 * scroll state in an internally inconsistent state. The scrollbar would've
39 * been scrolled correctly, but the body wasn't.
41 * This was due to optimizations that didn't keep up with the promises, so
42 * to say. So the optimizations were removed.
45 public void testScrollRaceCondition() {
46 scrollVerticallyTo(40);
47 String originalStyle = getTBodyStyle();
48 selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_ALL_INSERT_SCROLL);
50 // body should be scrolled to exactly the same spot. (not 0)
51 assertEquals(originalStyle, getTBodyStyle());
55 public void scrollToBottomAndRemoveHeader() throws Exception {
56 scrollVerticallyTo(999999); // to bottom
59 * apparently the scroll event isn't fired by the time the next assert
64 assertEquals("Unexpected last row cell before header removal",
65 "Row 99: 0,99", getBodyCell(-1, 0).getText());
66 selectMenuPath(COLUMNS_AND_ROWS, HEADER_ROWS,
67 REMOVE_ONE_ROW_FROM_BEGINNING);
68 assertEquals("Unexpected last row cell after header removal",
69 "Row 99: 0,99", getBodyCell(-1, 0).getText());
74 public void scrollToBottomAndRemoveFooter() throws Exception {
75 scrollVerticallyTo(999999); // to bottom
78 * apparently the scroll event isn't fired by the time the next assert
83 assertEquals("Unexpected last row cell before footer removal",
84 "Row 99: 0,99", getBodyCell(-1, 0).getText());
85 selectMenuPath(COLUMNS_AND_ROWS, FOOTER_ROWS,
86 REMOVE_ONE_ROW_FROM_BEGINNING);
87 assertEquals("Unexpected last row cell after footer removal",
88 "Row 99: 0,99", getBodyCell(-1, 0).getText());
91 private String getTBodyStyle() {
92 WebElement tbody = getEscalator().findElement(By.tagName("tbody"));
93 return tbody.getAttribute("style");