123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- /*
- * 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.assertEquals;
- import static org.junit.Assert.assertNotEquals;
- 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 {
-
- /**
- * The scroll position of the Escalator when scrolled all the way down, to
- * reveal the 100:th row.
- */
- private static final int BOTTOM_SCROLL_POSITION = 1857;
-
- @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));
- }
-
- @Test
- public void testResizeColToFit() {
- openTestURL();
- selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
-
- int originalWidth = getBodyCell(0, 0).getSize().getWidth();
- selectMenuPath(COLUMNS_AND_ROWS, COLUMNS,
- RESIZE_FIRST_COLUMN_TO_MAX_WIDTH);
- int newWidth = getBodyCell(0, 0).getSize().getWidth();
- assertNotEquals("Column width should've changed", originalWidth,
- newWidth);
- }
-
- @Test
- public void testRemoveMoreThanPagefulAtBottomWhileScrolledToBottom()
- throws Exception {
- openTestURL();
- selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
-
- scrollVerticallyTo(BOTTOM_SCROLL_POSITION);
- selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_50_ROWS_FROM_BOTTOM);
- assertEquals("Row 49: 0,49", getBodyCell(-1, 0).getText());
-
- scrollVerticallyTo(0);
-
- // let the DOM organize itself
- Thread.sleep(500);
-
- // if something goes wrong, it'll explode before this.
- assertEquals("Row 0: 0,0", getBodyCell(0, 0).getText());
- }
-
- @Test
- public void testRemoveMoreThanPagefulAtBottomWhileScrolledAlmostToBottom()
- throws Exception {
- openTestURL();
- selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
-
- // bottom minus 15 rows.
- scrollVerticallyTo(BOTTOM_SCROLL_POSITION - 15 * 20);
- selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_50_ROWS_FROM_BOTTOM);
- assertEquals("Row 49: 0,49", getBodyCell(-1, 0).getText());
-
- scrollVerticallyTo(0);
-
- // let the DOM organize itself
- Thread.sleep(500);
-
- // if something goes wrong, it'll explode before this.
- assertEquals("Row 0: 0,0", getBodyCell(0, 0).getText());
- }
-
- @Test
- public void testRemoveMoreThanPagefulNearBottomWhileScrolledToBottom()
- throws Exception {
- openTestURL();
- selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
-
- scrollVerticallyTo(BOTTOM_SCROLL_POSITION);
- selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS,
- REMOVE_50_ROWS_FROM_ALMOST_BOTTOM);
- assertEquals("Row 49: 0,99", getBodyCell(-1, 0).getText());
-
- scrollVerticallyTo(0);
-
- // let the DOM organize itself
- Thread.sleep(500);
-
- // if something goes wrong, it'll explode before this.
- assertEquals("Row 0: 0,0", getBodyCell(0, 0).getText());
- }
-
- @Test
- public void testRemoveMoreThanPagefulNearBottomWhileScrolledAlmostToBottom()
- throws Exception {
- openTestURL();
- selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
-
- // bottom minus 15 rows.
- scrollVerticallyTo(BOTTOM_SCROLL_POSITION - 15 * 20);
- selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS,
- REMOVE_50_ROWS_FROM_ALMOST_BOTTOM);
-
- // let the DOM organize itself
- Thread.sleep(500);
- assertEquals("Row 49: 0,99", getBodyCell(-1, 0).getText());
-
- scrollVerticallyTo(0);
-
- // let the DOM organize itself
- Thread.sleep(500);
-
- // if something goes wrong, it'll explode before this.
- assertEquals("Row 0: 0,0", getBodyCell(0, 0).getText());
- }
- }
|