summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-01-15 08:19:13 +0200
committerVaadin Code Review <review@vaadin.com>2016-03-05 11:29:10 +0000
commita00fd32041018899a4bb43268895525e67be32e9 (patch)
tree8ee27a30dbcd76da8087fee44866a47133bffaad /uitest/src/com
parent39640d188b0c7b9964d5df34f97a83839f2b3732 (diff)
downloadvaadin-framework-a00fd32041018899a4bb43268895525e67be32e9.tar.gz
vaadin-framework-a00fd32041018899a4bb43268895525e67be32e9.zip
Make table take parent enable state changes into account (#19455)
Change-Id: I11d9e7bcdc3471157b9c21881d463ef5a747d2c1
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChange.java84
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java55
2 files changed, 139 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChange.java b/uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChange.java
new file mode 100644
index 0000000000..9aeb25002d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChange.java
@@ -0,0 +1,84 @@
+/*
+ * 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.table;
+
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+public class TableParentEnabledStateChange extends AbstractTestUIWithLog {
+
+ private Button toggle;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ addComponent(new Label(
+ "Toggling the enabled state of the custom component will break the selectability of the row in the table. "));
+
+ final MyCustomComponent customComponent = new MyCustomComponent();
+
+ toggle = new Button("Toggle enabled state ; "
+ + customComponent.isEnabled());
+ toggle.addClickListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ customComponent.setEnabled(!customComponent.isEnabled());
+ toggle.setCaption("Toggle enabled state ; "
+ + customComponent.isEnabled());
+ }
+ });
+ addComponent(toggle);
+ addComponent(customComponent);
+
+ }
+
+ class MyCustomComponent extends CustomComponent {
+
+ private static final long serialVersionUID = 1L;
+ private FormLayout root;
+ private Table table;
+ private Button toggle;
+
+ public MyCustomComponent() {
+ root = new FormLayout();
+ setCompositionRoot(root);
+ setWidth("300px");
+ setHeight("300px");
+
+ table = new Table();
+ table.setWidth("200px");
+ table.setHeight("150px");
+ table.setSelectable(true);
+
+ IndexedContainer container = new IndexedContainer();
+ container.addContainerProperty("name", String.class,
+ "Select this item");
+ container.addItem(1);
+ table.setContainerDataSource(container);
+
+ root.addComponent(table);
+ }
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java b/uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java
new file mode 100644
index 0000000000..5fde9c385e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.table;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.testbench.elements.TableRowElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class TableParentEnabledStateChangeTest extends SingleBrowserTest {
+
+ @Test
+ public void tableEnabledShouldFollowParent() {
+ openTestURL();
+ TableElement table = $(TableElement.class).first();
+ TableRowElement row = table.getRow(0);
+
+ ButtonElement button = $(ButtonElement.class).first();
+
+ row.click();
+ Assert.assertTrue(isSelected(row));
+
+ // Disable
+ button.click();
+ Assert.assertTrue(isSelected(row));
+ row.click(); // Should have no effect
+ Assert.assertTrue(isSelected(row));
+
+ // Enable
+ button.click();
+ Assert.assertTrue(isSelected(row));
+ row.click(); // Should deselect
+ Assert.assertFalse(isSelected(row));
+ }
+
+ private boolean isSelected(TableRowElement row) {
+ return hasCssClass(row, "v-selected");
+ }
+}