summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/application
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-06-19 15:34:29 +0300
committerVaadin Code Review <review@vaadin.com>2015-12-02 11:37:37 +0000
commit3cf57002b11ad400b8d4a33de1104b68a37e681a (patch)
treef01e0d9c88b7baaaacb31a1038a99840b805b627 /uitest/src/com/vaadin/tests/application
parent907e689a418f04013a58428e687ebc5132b0f45d (diff)
downloadvaadin-framework-3cf57002b11ad400b8d4a33de1104b68a37e681a.tar.gz
vaadin-framework-3cf57002b11ad400b8d4a33de1104b68a37e681a.zip
Detect hierarchy changes not sent to the client (#18317)
Change-Id: I77b420738738a42ff50e2a509e4ac4072b1b6e1f
Diffstat (limited to 'uitest/src/com/vaadin/tests/application')
-rw-r--r--uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java70
-rw-r--r--uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java50
2 files changed, 120 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java b/uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java
new file mode 100644
index 0000000000..3f55e7bd60
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java
@@ -0,0 +1,70 @@
+/*
+ * 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.application;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.SelectiveRenderer;
+
+public class MissingHierarchyDetection extends AbstractTestUI {
+
+ private boolean isChildRendered = true;
+ private BrokenCssLayout layout = new BrokenCssLayout();
+
+ public class BrokenCssLayout extends CssLayout implements SelectiveRenderer {
+ public BrokenCssLayout() {
+ setCaption("Broken layout");
+ Label label = new Label("Child component");
+ label.setId("label");
+ addComponent(label);
+ }
+
+ @Override
+ public boolean isRendered(Component childComponent) {
+ return isChildRendered;
+ }
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(layout);
+ addComponent(new Button("Toggle properly", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ toggle(true);
+ }
+ }));
+ addComponent(new Button("Toggle improperly",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ toggle(false);
+ }
+ }));
+ }
+
+ private void toggle(boolean properly) {
+ isChildRendered = !isChildRendered;
+ if (properly) {
+ layout.markAsDirtyRecursive();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java b/uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java
new file mode 100644
index 0000000000..3d43b8f885
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.application;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class MissingHierarchyDetectionTest extends SingleBrowserTest {
+ @Test
+ public void testMissingHierarchyDetection() {
+ openTestURL();
+
+ Assert.assertTrue(isElementPresent(By.id("label")));
+
+ ButtonElement toggleProperly = $(ButtonElement.class).caption(
+ "Toggle properly").first();
+
+ toggleProperly.click();
+ assertNoSystemNotifications();
+ Assert.assertFalse(isElementPresent(By.id("label")));
+
+ toggleProperly.click();
+ assertNoSystemNotifications();
+ Assert.assertTrue(isElementPresent(LabelElement.class));
+
+ ButtonElement toggleInproperly = $(ButtonElement.class).caption(
+ "Toggle improperly").first();
+ toggleInproperly.click();
+
+ assertSystemNotification();
+ }
+}