aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/table/TableContextMenuAndIconsTest.java
blob: 5410477af1f9c42a06d4d98f6b5179892dd4f790 (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
package com.vaadin.tests.components.table;

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

import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class TableContextMenuAndIconsTest extends MultiBrowserTest {
    @Override
    protected Class<?> getUIClass() {
        return com.vaadin.tests.components.table.Tables.class;
    }

    @Test
    public void tableContextMenuWithIcons() throws Exception {
        openTestURL();
        /* Hide event log */
        selectMenuPath("Settings", "Show event log");
        /* Simple context menu */
        selectMenuPath("Component", "Features", "Context menu",
                "Item without icon");
        contextClickCell(1, 1);
        compareScreen("contextmenu-noicon");
        /* Two actions, without and with icon */
        selectMenuPath("Component", "Features", "Context menu",
                "With and without icon");
        contextClickCell(4, 2);
        compareScreen("caption-only-and-has-icon");
        /* Large icon */
        selectMenuPath("Component", "Features", "Context menu",
                "Only one large icon");
        contextClickCell(4, 2);
        compareScreen("large-icon");
        /*
         * Simple context menu again to ensure it is properly updated (icons
         * removed)
         */
        selectMenuPath("Component", "Features", "Context menu",
                "Item without icon");
        contextClickCell(1, 1);
        compareScreen("contextmenu-noicon");
        /* Empty context menu */
        selectMenuPath("Component", "Features", "Context menu", "Empty");
        contextClickCell(3, 3);
        compareScreen("contextmenu-empty");
    }

    private void contextClickCell(int row, int column) {
        TestBenchElement cell = $(TableElement.class).first().getCell(row,
                column);
        new Actions(driver).contextClick(cell).perform();
    }

}