aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java
blob: 2dc19cdc3fa9affa9c3627b03d2b3211868d629b (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
package com.vaadin.tests.components.grid;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;

@TestCategory("grid")
public class GridMultiSelectionOnInitTest extends MultiBrowserTest {

    @Test
    public void testSelectAllCheckBoxExists() {
        openTestURL();
        assertTrue("The select all checkbox was missing.",
                $(GridElement.class).first().getHeaderCell(0, 0)
                        .isElementPresent(By.tagName("input")));
    }

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

        GridElement.GridCellElement selectAllCell = $(GridElement.class).first()
                .getHeaderCell(0, 0);

        new Actions(getDriver()).moveToElement(selectAllCell, 2, 2).click()
                .perform();

        WebElement selectAllCheckbox = selectAllCell
                .findElement(By.cssSelector("input"));
        assertThat(selectAllCheckbox.isSelected(), is(true));
    }

    @Test
    public void testSetSelectedUpdatesClient() {
        openTestURL();
        assertFalse("Rows should not be selected initially.",
                $(GridElement.class).first().getRow(0).isSelected());
        $(ButtonElement.class).first().click();
        assertTrue("Rows should be selected after button click.",
                $(GridElement.class).first().getRow(0).isSelected());
    }

    @Test
    public void testInitialSelection() {
        openTestURL("initialSelection=yes");

        assertTrue("Initial selection should be visible",
                $(GridElement.class).first().getRow(1).isSelected());
    }

}