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.Test;
21 import org.openqa.selenium.WebElement;
23 import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
25 public class EscalatorColspanTest extends EscalatorBasicClientFeaturesTest {
26 private static final int NO_COLSPAN = 1;
29 public void testNoColspan() {
33 assertEquals(NO_COLSPAN, getColSpan(getHeaderCell(0, 0)));
34 assertEquals(NO_COLSPAN, getColSpan(getBodyCell(0, 0)));
35 assertEquals(NO_COLSPAN, getColSpan(getFooterCell(0, 0)));
39 public void testColspan() {
43 int firstCellWidth = getBodyCell(0, 0).getSize().getWidth();
44 int secondCellWidth = getBodyCell(0, 1).getSize().getWidth();
45 int doubleCellWidth = firstCellWidth + secondCellWidth;
47 selectMenuPath(FEATURES, COLUMN_SPANNING, COLSPAN_NORMAL);
49 WebElement bodyCell = getBodyCell(0, 0);
50 assertEquals("Cell was not spanned correctly", 2, getColSpan(bodyCell));
52 "Spanned cell's width was not the sum of the previous cells ("
53 + firstCellWidth + " + " + secondCellWidth + ")",
54 doubleCellWidth, bodyCell.getSize().getWidth(), 1);
58 public void testColspanToggle() {
62 int singleCellWidth = getBodyCell(0, 0).getSize().getWidth();
64 selectMenuPath(FEATURES, COLUMN_SPANNING, COLSPAN_NORMAL);
65 selectMenuPath(FEATURES, COLUMN_SPANNING, COLSPAN_NONE);
67 WebElement bodyCell = getBodyCell(0, 0);
68 assertEquals(NO_COLSPAN, getColSpan(bodyCell));
69 assertEquals(singleCellWidth, bodyCell.getSize().getWidth(), 1);
72 private static int getColSpan(WebElement cell) {
73 String attribute = cell.getAttribute("colspan");
74 if (attribute == null) {
77 return Integer.parseInt(attribute);