123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package com.vaadin.tests.components.treegrid;
-
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
-
- import com.vaadin.testbench.elements.TreeGridElement;
- import com.vaadin.tests.tb3.SingleBrowserTest;
-
- public class TreeGridCollapseDisabledTest extends SingleBrowserTest {
-
- private TreeGridElement grid;
-
- @Override
- protected Class<?> getUIClass() {
- return TreeGridBasicFeatures.class;
- }
-
- @Before
- public void before() {
- openTestURL();
- grid = $(TreeGridElement.class).first();
- }
-
- @Test
- public void collapse_disabled_for_all() {
- selectMenuPath("Component", "Features", "Collapse allowed",
- "all disabled");
-
- // Assert first and second row can be expanded, but not collapsed
- assertExpandRow(0);
- assertCollapseRowDisabled(0);
-
- assertExpandRow(1);
- assertCollapseRowDisabled(1);
- }
-
- @Test
- public void collapse_disabled_for_depth0() {
- selectMenuPath("Component", "Features", "Collapse allowed",
- "depth 0 disabled");
-
- // Assert first row expands
- assertExpandRow(0);
-
- // Assert second row expands and collapses
- assertExpandRow(1);
- assertCollapseRow(1);
-
- // Assert first row does not collapse
- assertCollapseRowDisabled(0);
- }
-
- @Test
- public void collapse_disabled_for_depth1() {
- selectMenuPath("Component", "Features", "Collapse allowed",
- "depth 1 disabled");
-
- // Assert first row expands
- assertExpandRow(0);
-
- // Assert second row expands but does not collapse
- assertExpandRow(1);
- assertCollapseRowDisabled(1);
-
- // Assert first row still collapses
- assertCollapseRow(0);
- }
-
- @Test
- public void collapse_disabled_mode_change_with_expanded_rows() {
- // Assert first row expands
- assertExpandRow(0);
-
- // Assert second row expands and collapses
- assertExpandRow(1);
- assertCollapseRow(1);
-
- selectMenuPath("Component", "Features", "Collapse allowed",
- "depth 1 disabled");
-
- Assert.assertTrue("First row should still be expanded",
- grid.isRowExpanded(0, 0));
-
- // Assert second row expands but does not collapse
- assertExpandRow(1);
- assertCollapseRowDisabled(1);
-
- // Assert first row still collapses
- assertCollapseRow(0);
- }
-
- private void assertExpandRow(int row) {
- Assert.assertFalse(grid.isRowExpanded(row, 0));
- grid.expandWithClick(row);
- Assert.assertTrue(grid.isRowExpanded(row, 0));
- }
-
- private void assertCollapseRow(int row) {
- Assert.assertTrue("Row not expanded", grid.isRowExpanded(row, 0));
- grid.collapseWithClick(row);
- Assert.assertFalse("Row did not collapse", grid.isRowExpanded(row, 0));
- }
-
- private void assertCollapseRowDisabled(int row) {
- Assert.assertTrue("Row not expanded", grid.isRowExpanded(row, 0));
- grid.collapseWithClick(row);
- Assert.assertTrue("Row should not collapse",
- grid.isRowExpanded(row, 0));
- }
- }
|