aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0Test.java
blob: d88c6ba7ca86735f12349f72afecd71e79f180c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * 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.treetable;

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.util.List;

import org.junit.Test;
import org.openqa.selenium.WebElement;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.TreeTableElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
 * Tests expanding TreeTable rows when page length is zero.
 * 
 * @author Vaadin Ltd
 */
public class TreeTablePartialUpdatesPageLength0Test extends MultiBrowserTest {

    @Test
    public void testExpanding() throws IOException {
        openTestURL();

        TreeTableElement treeTable = $(TreeTableElement.class).first();
        List<WebElement> rows = treeTable.findElement(
                By.className("v-table-body")).findElements(By.tagName("tr"));
        assertEquals("unexpected row count", 4, rows.size());
        assertEquals("unexpected contents", "root1", treeTable.getCell(0, 0)
                .getText());
        assertEquals("unexpected contents", "root2", treeTable.getCell(1, 0)
                .getText());
        assertEquals("unexpected contents", "root3", treeTable.getCell(2, 0)
                .getText());
        assertEquals("unexpected contents", "END", treeTable.getCell(3, 0)
                .getText());

        // expand first row, should have 10 children
        treeTable.getCell(0, 0)
                .findElement(By.className("v-treetable-treespacer")).click();

        treeTable = $(TreeTableElement.class).first();
        rows = treeTable.findElement(By.className("v-table-body"))
                .findElements(By.tagName("tr"));
        assertEquals("unexpected row count", 14, rows.size());

        // expand root3, should have 200 children
        assertEquals("unexpected contents", "root3", treeTable.getCell(12, 0)
                .getText());
        treeTable.getCell(12, 0)
                .findElement(By.className("v-treetable-treespacer")).click();

        // expand root2, should have 200 children
        assertEquals("unexpected contents", "root2", treeTable.getCell(11, 0)
                .getText());
        treeTable.getCell(11, 0)
                .findElement(By.className("v-treetable-treespacer")).click();

        treeTable = $(TreeTableElement.class).first();
        rows = treeTable.findElement(By.className("v-table-body"))
                .findElements(By.tagName("tr"));
        assertEquals("unexpected row count", 414, rows.size());

        // scroll all the way to the bottom
        WebElement ui = findElement(By.className("v-ui"));
        testBenchElement(ui).scroll(12500);

        compareScreen("bottom");
    }
}