aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/grid
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2015-03-18 10:05:47 +0200
committerVaadin Code Review <review@vaadin.com>2015-03-19 07:33:33 +0000
commit2be1e43d7081f0bc2c5f905d6b007fe597934ae3 (patch)
treef89f209bc439e881078eb915d8d1acf27cc8a8b8 /uitest/src/com/vaadin/tests/components/grid
parent4d5f6cf73f84bd0f68f05eb534699bddb898f9f1 (diff)
downloadvaadin-framework-2be1e43d7081f0bc2c5f905d6b007fe597934ae3.tar.gz
vaadin-framework-2be1e43d7081f0bc2c5f905d6b007fe597934ae3.zip
Adds server side column hiding API to Grid (#17023)
Change-Id: Ic00e873176f499dfc45976439e09d712932775da
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/grid')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java89
2 files changed, 131 insertions, 1 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 e9f6bfdbb9..aeeaa25ac3 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -52,6 +52,8 @@ import com.vaadin.ui.Grid.CellStyleGenerator;
import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.Grid.ColumnReorderEvent;
import com.vaadin.ui.Grid.ColumnReorderListener;
+import com.vaadin.ui.Grid.ColumnVisibilityChangeEvent;
+import com.vaadin.ui.Grid.ColumnVisibilityChangeListener;
import com.vaadin.ui.Grid.FooterCell;
import com.vaadin.ui.Grid.HeaderCell;
import com.vaadin.ui.Grid.HeaderRow;
@@ -120,6 +122,16 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
};
+ private ColumnVisibilityChangeListener columnVisibilityListener = new ColumnVisibilityChangeListener() {
+ @Override
+ public void columnVisibilityChanged(ColumnVisibilityChangeEvent event) {
+ log("Visibility changed: "//
+ + "propertyId: " + event.getColumn().getPropertyId() //
+ + ", isHidden: " + event.getColumn().isHidden() //
+ + ", userOriginated: " + event.isUserOriginated());
+ }
+ };
+
@Override
@SuppressWarnings("unchecked")
protected Grid constructComponent() {
@@ -532,6 +544,17 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
}
});
+ createBooleanAction("ColumnVisibilityChangeListener", "State", false,
+ new Command<Grid, Boolean>() {
+ @Override
+ public void execute(Grid grid, Boolean value, Object data) {
+ if (value) {
+ grid.addColumnVisibilityChangeListener(columnVisibilityListener);
+ } else {
+ grid.removeColumnVisibilityChangeListener(columnVisibilityListener);
+ }
+ }
+ });
createBooleanAction("Single select allow deselect", "State",
singleSelectAllowDeselect, new Command<Grid, Boolean>() {
@@ -676,6 +699,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}, null);
}
+ @SuppressWarnings("boxing")
protected void createColumnActions() {
createCategory("Columns", null);
@@ -736,6 +760,24 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
}, c);
+ createBooleanAction("Hidable", getColumnProperty(c), false,
+ new Command<Grid, Boolean>() {
+ @Override
+ public void execute(Grid c, Boolean hidable,
+ Object propertyId) {
+ grid.getColumn(propertyId).setHidable(hidable);
+ }
+ }, getColumnProperty(c));
+
+ createBooleanAction("Hidden", getColumnProperty(c), false,
+ new Command<Grid, Boolean>() {
+ @Override
+ public void execute(Grid c, Boolean hidden,
+ Object propertyId) {
+ grid.getColumn(propertyId).setHidden(hidden);
+ }
+ }, getColumnProperty(c));
+
createCategory("Column " + c + " Width", getColumnProperty(c));
createClickAction("Auto", "Column " + c + " Width",
@@ -753,7 +795,6 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
createClickAction("25.5px", "Column " + c + " Width",
new Command<Grid, Void>() {
@Override
- @SuppressWarnings("boxing")
public void execute(Grid grid, Void value,
Object columnIndex) {
grid.getColumns().get((Integer) columnIndex)
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java
new file mode 100644
index 0000000000..8fb733dfa0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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 static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.testbench.annotations.RunLocally;
+import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+
+@TestCategory("grid")
+@RunLocally(Browser.PHANTOMJS)
+public class GridColumnVisibilityTest extends GridBasicFeaturesTest {
+
+ private static final String[] TOGGLE_LISTENER = new String[] { "Component",
+ "State", "ColumnVisibilityChangeListener" };
+ private static final String[] TOGGLE_HIDE_COLUMN_0 = new String[] {
+ "Component", "Columns", "Column 0", "Hidden" };
+
+ private static final String COLUMN_0_BECAME_HIDDEN_MSG = "Visibility "
+ + "changed: propertyId: Column 0, isHidden: true";
+ private static final String COLUMN_0_BECAME_UNHIDDEN_MSG = "Visibility "
+ + "changed: propertyId: Column 0, isHidden: false";
+
+ @Before
+ public void setUp() {
+ openTestURL();
+ }
+
+ @Test
+ public void columnIsNotShownWhenHidden() {
+ assertEquals("column 0", getGridElement().getHeaderCell(0, 0).getText()
+ .toLowerCase());
+
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+ assertEquals("column 1", getGridElement().getHeaderCell(0, 0).getText()
+ .toLowerCase());
+ }
+
+ @Test
+ public void columnIsShownWhenUnhidden() {
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+ assertEquals("column 0", getGridElement().getHeaderCell(0, 0).getText()
+ .toLowerCase());
+ }
+
+ @Test
+ public void registeringListener() {
+ assertFalse(logContainsText(COLUMN_0_BECAME_HIDDEN_MSG));
+ selectMenuPath(TOGGLE_LISTENER);
+ assertFalse(logContainsText(COLUMN_0_BECAME_HIDDEN_MSG));
+
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+ assertTrue(logContainsText(COLUMN_0_BECAME_HIDDEN_MSG));
+
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+ assertTrue(logContainsText(COLUMN_0_BECAME_UNHIDDEN_MSG));
+ }
+
+ @Test
+ public void deregisteringListener() {
+ selectMenuPath(TOGGLE_LISTENER);
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+
+ selectMenuPath(TOGGLE_LISTENER);
+ selectMenuPath(TOGGLE_HIDE_COLUMN_0);
+ assertFalse(logContainsText(COLUMN_0_BECAME_UNHIDDEN_MSG));
+ }
+}