aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-07-06 10:01:17 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-09-01 11:58:57 +0000
commit53a4b2c77a6af86c157884c62e6193911242a7f9 (patch)
tree033b8b64744abb3a8b63df52a748261b656247cd /uitest
parent9899aa2009d32e375ccd21e2edf50cb6d2d557bb (diff)
downloadvaadin-framework-53a4b2c77a6af86c157884c62e6193911242a7f9.tar.gz
vaadin-framework-53a4b2c77a6af86c157884c62e6193911242a7f9.zip
Refactor Grid SelectionModels as extensions (#18624)
This patch removes all selection related variables and API from several core parts of Grid. Change-Id: Idb7aa48fda69ded1ef58a69c1f7dbc78b7f52a54
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModel.java37
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModelTest.java58
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/MySelectionModelConnector.java61
3 files changed, 156 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModel.java b/uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModel.java
new file mode 100644
index 0000000000..008c24cdd3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModel.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.ui.Grid.MultiSelectionModel;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class GridCustomSelectionModel extends AbstractTestUI {
+
+ public static class MySelectionModel extends MultiSelectionModel {
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ PersonTestGrid grid = new PersonTestGrid(500);
+ grid.setSelectionModel(new MySelectionModel());
+ addComponent(grid);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModelTest.java b/uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModelTest.java
new file mode 100644
index 0000000000..976e1e78fe
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridCustomSelectionModelTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridCustomSelectionModelTest extends MultiBrowserTest {
+
+ @Test
+ public void testCustomSelectionModel() {
+ setDebug(true);
+ openTestURL();
+
+ GridElement grid = $(GridElement.class).first();
+ GridCellElement cell = grid.getCell(0, 0);
+ assertTrue("First column of Grid should not have an input element",
+ cell.findElements(By.className("input")).isEmpty());
+
+ assertFalse("Row should not be selected initially", grid.getRow(0)
+ .isSelected());
+
+ cell.click(5, 5);
+ assertTrue("Click should select row", grid.getRow(0).isSelected());
+ cell.click(5, 5);
+ assertFalse("Click should deselect row", grid.getRow(0).isSelected());
+
+ grid.sendKeys(Keys.SPACE);
+ assertTrue("Space should select row", grid.getRow(0).isSelected());
+ grid.sendKeys(Keys.SPACE);
+ assertFalse("Space should deselect row", grid.getRow(0).isSelected());
+
+ assertNoErrorNotifications();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/MySelectionModelConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/MySelectionModelConnector.java
new file mode 100644
index 0000000000..81a9ab5bf1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/MySelectionModelConnector.java
@@ -0,0 +1,61 @@
+/*
+ * 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.widgetset.client.grid;
+
+import com.vaadin.client.ServerConnector;
+import com.vaadin.client.connectors.MultiSelectionModelConnector;
+import com.vaadin.client.renderers.ComplexRenderer;
+import com.vaadin.client.widget.grid.selection.ClickSelectHandler;
+import com.vaadin.client.widget.grid.selection.SelectionModel.Multi;
+import com.vaadin.client.widgets.Grid;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.components.grid.GridCustomSelectionModel.MySelectionModel;
+
+import elemental.json.JsonObject;
+
+@Connect(MySelectionModel.class)
+public class MySelectionModelConnector extends MultiSelectionModelConnector {
+
+ private ClickSelectHandler<JsonObject> handler;
+
+ @Override
+ protected void extend(ServerConnector target) {
+ super.extend(target);
+ handler = new ClickSelectHandler<JsonObject>(getGrid());
+ }
+
+ @Override
+ public void onUnregister() {
+ super.onUnregister();
+ handler.removeHandler();
+ handler = null;
+ }
+
+ @Override
+ protected Multi<JsonObject> createSelectionModel() {
+ return new MySelectionModel();
+ }
+
+ public class MySelectionModel extends MultiSelectionModel {
+
+ @Override
+ protected ComplexRenderer<Boolean> createSelectionColumnRenderer(
+ Grid<JsonObject> grid) {
+ // No Selection Column.
+ return null;
+ }
+ }
+}