summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-09-29 17:57:14 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2015-10-08 13:10:46 +0300
commited5b1f2c279c37ba80da179f92fd66a4e43342f9 (patch)
tree10b9f0017958a07ad517302c715d021b0faf853b /uitest
parentab5f80bb20550a04bb0b6cf0c2208863b41dcf91 (diff)
downloadvaadin-framework-ed5b1f2c279c37ba80da179f92fd66a4e43342f9.tar.gz
vaadin-framework-ed5b1f2c279c37ba80da179f92fd66a4e43342f9.zip
Add API for setting Grid columns resizable (#16838)
By default columns can be drag-resized by the user. This can be changed on a column-by-column basis. Change-Id: I8354e270db9affe865d1444d6cccbe8c839a3b5b
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java25
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java87
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java11
3 files changed, 112 insertions, 11 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index 04d7cbbb09..e761df2b20 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -1008,6 +1008,18 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
}, c);
+ createBooleanAction("Resizable", getColumnProperty(c), true,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid grid, Boolean value,
+ Object columnIndex) {
+ Object propertyId = getColumnProperty((Integer) columnIndex);
+ Column column = grid.getColumn(propertyId);
+ column.setResizable(value);
+ }
+ }, c);
+
createBooleanAction("Hidable", getColumnProperty(c),
isColumnHidableByDefault(c), new Command<Grid, Boolean>() {
@Override
@@ -1165,6 +1177,19 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}, c);
}
+
+ createBooleanAction("All columns resizable", "Columns", false,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid c, Boolean value, Object data) {
+ for (Column col : grid.getColumns()) {
+ col.setResizable(value);
+ }
+
+ }
+ });
+
createBooleanAction("All columns hidable", "Columns", false,
new Command<Grid, Boolean>() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java
new file mode 100644
index 0000000000..827a132eb9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnResizeTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.grid.basicfeatures.server;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures;
+import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+
+@TestCategory("grid")
+public class GridColumnResizeTest extends GridBasicFeaturesTest {
+
+ @Before
+ public void before() {
+ openTestURL();
+ }
+
+ @Test
+ public void testResizeHandlesPresentInDefaultHeader() {
+ for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) {
+ assertResizable(i, true);
+ }
+ }
+
+ @Test
+ public void testResizeHandlesNotInNonDefaultHeader() {
+ selectMenuPath("Component", "Header", "Prepend row");
+
+ for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) {
+ assertResizable(getGridElement().getHeaderCell(0, i), false);
+ assertResizable(getGridElement().getHeaderCell(1, i), true);
+ }
+ }
+
+ @Test
+ public void testResizeHandlesNotInFooter() {
+ selectMenuPath("Component", "Footer", "Visible");
+ for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) {
+ assertResizable(getGridElement().getFooterCell(0, i), false);
+ }
+ }
+
+ @Test
+ public void testToggleSetResizable() {
+ selectMenuPath("Component", "Columns", "Column 1", "Resizable");
+
+ for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) {
+ assertResizable(i, i != 1);
+ }
+
+ selectMenuPath("Component", "Columns", "Column 1", "Resizable");
+
+ for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) {
+ assertResizable(i, true);
+ }
+ }
+
+ private void assertResizable(int columnIndex, boolean resizable) {
+ assertResizable(getGridElement().getHeaderCell(0, columnIndex),
+ resizable);
+ }
+
+ private void assertResizable(GridCellElement cell, boolean resizable) {
+ assertEquals("Header resize handle present", resizable,
+ cell.isElementPresent(By
+ .cssSelector("div.v-grid-column-resize-handle")));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java
index 024e54260a..eb3d8672b3 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java
@@ -40,17 +40,6 @@ import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
public class GridStructureTest extends GridBasicFeaturesTest {
@Test
- public void testResizeHandlesPresent() {
- openTestURL();
-
- // Test that all column headers contain resize handles
- for (int i = 0; i < GridBasicFeatures.COLUMNS; ++i) {
- assertFalse(getGridElement().getHeaderCell(0, i).findElement(
- By.cssSelector("div.v-grid-column-resize-handle")) == null);
- }
- }
-
- @Test
public void testRemovingAllColumns() {
setDebug(true);
openTestURL();