]> source.dussan.org Git - vaadin-framework.git/blob
fbf8947ba97b7a7c23841ffee125b01f7513f8a2
[vaadin-framework.git] /
1 /*
2  * Copyright 2000-2016 Vaadin Ltd.
3  *
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
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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
14  * the License.
15  */
16 package com.vaadin.tests.components.treetable;
17
18 import static org.junit.Assert.assertEquals;
19
20 import java.io.IOException;
21 import java.util.List;
22
23 import org.junit.Test;
24 import org.openqa.selenium.WebElement;
25
26 import com.vaadin.testbench.By;
27 import com.vaadin.tests.tb3.MultiBrowserTest;
28 import com.vaadin.v7.testbench.customelements.TreeTableElement;
29
30 /**
31  * Tests expanding TreeTable rows when page length is zero.
32  *
33  * @author Vaadin Ltd
34  */
35 public class TreeTablePartialUpdatesPageLength0Test extends MultiBrowserTest {
36
37     @Test
38     public void testExpanding() throws IOException {
39         openTestURL();
40
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());
54
55         // expand first row, should have 10 children
56         treeTable.getCell(0, 0)
57                 .findElement(By.className("v-treetable-treespacer")).click();
58
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());
63
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();
69
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();
75
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());
80
81         // scroll all the way to the bottom
82         WebElement ui = findElement(By.className("v-ui"));
83         testBenchElement(ui).scroll(12500);
84
85         compareScreen("bottom");
86     }
87 }