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.treetable;
18 import static org.junit.Assert.assertEquals;
20 import java.io.IOException;
21 import java.util.List;
23 import org.junit.Test;
24 import org.openqa.selenium.WebElement;
26 import com.vaadin.testbench.By;
27 import com.vaadin.tests.tb3.MultiBrowserTest;
28 import com.vaadin.v7.testbench.customelements.TreeTableElement;
31 * Tests expanding TreeTable rows when page length is zero.
35 public class TreeTablePartialUpdatesPageLength0Test extends MultiBrowserTest {
38 public void testExpanding() throws IOException {
41 TreeTableElement treeTable = $(TreeTableElement.class).first();
42 List<WebElement> rows = treeTable
43 .findElement(By.className("v-table-body"))
44 .findElements(By.tagName("tr"));
45 assertEquals("unexpected row count", 4, rows.size());
46 assertEquals("unexpected contents", "root1",
47 treeTable.getCell(0, 0).getText());
48 assertEquals("unexpected contents", "root2",
49 treeTable.getCell(1, 0).getText());
50 assertEquals("unexpected contents", "root3",
51 treeTable.getCell(2, 0).getText());
52 assertEquals("unexpected contents", "END",
53 treeTable.getCell(3, 0).getText());
55 // expand first row, should have 10 children
56 treeTable.getCell(0, 0)
57 .findElement(By.className("v-treetable-treespacer")).click();
59 treeTable = $(TreeTableElement.class).first();
60 rows = treeTable.findElement(By.className("v-table-body"))
61 .findElements(By.tagName("tr"));
62 assertEquals("unexpected row count", 14, rows.size());
64 // expand root3, should have 200 children
65 assertEquals("unexpected contents", "root3",
66 treeTable.getCell(12, 0).getText());
67 treeTable.getCell(12, 0)
68 .findElement(By.className("v-treetable-treespacer")).click();
70 // expand root2, should have 200 children
71 assertEquals("unexpected contents", "root2",
72 treeTable.getCell(11, 0).getText());
73 treeTable.getCell(11, 0)
74 .findElement(By.className("v-treetable-treespacer")).click();
76 treeTable = $(TreeTableElement.class).first();
77 rows = treeTable.findElement(By.className("v-table-body"))
78 .findElements(By.tagName("tr"));
79 assertEquals("unexpected row count", 414, rows.size());
81 // scroll all the way to the bottom
82 WebElement ui = findElement(By.className("v-ui"));
83 testBenchElement(ui).scroll(12500);
85 compareScreen("bottom");