summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/widgetset/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-12-04 16:41:49 +0200
committerVaadin Code Review <review@vaadin.com>2012-12-07 08:48:06 +0000
commit50665cb1d34c84bc478cd5306f6c6151fe4d0bc3 (patch)
tree329772d20abe91f084980cc203fdeec046283620 /uitest/src/com/vaadin/tests/widgetset/client
parentece1ab1fa500ad7142b80534dffee0b3883a984e (diff)
downloadvaadin-framework-50665cb1d34c84bc478cd5306f6c6151fe4d0bc3.tar.gz
vaadin-framework-50665cb1d34c84bc478cd5306f6c6151fe4d0bc3.zip
Reset state before sending hierarchy event to removed connector (#10151)
Change-Id: If4f3e23a1d58c9f1cec7fc7d5e4e3f470932162f
Diffstat (limited to 'uitest/src/com/vaadin/tests/widgetset/client')
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java68
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java25
2 files changed, 93 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java
new file mode 100644
index 0000000000..948c1ece3d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnector.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2012 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;
+
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.vaadin.client.ComponentConnector;
+import com.vaadin.client.ConnectorHierarchyChangeEvent;
+import com.vaadin.client.ui.AbstractSingleComponentContainerConnector;
+import com.vaadin.shared.Connector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.widgetset.server.UseStateFromHierachyComponent;
+
+@Connect(UseStateFromHierachyComponent.class)
+public class UseStateFromHierachyChangeConnector extends
+ AbstractSingleComponentContainerConnector {
+
+ @Override
+ public SimplePanel getWidget() {
+ return (SimplePanel) super.getWidget();
+ }
+
+ @Override
+ public UseStateFromHierachyChangeConnectorState getState() {
+ return (UseStateFromHierachyChangeConnectorState) super.getState();
+ }
+
+ @Override
+ public void updateCaption(ComponentConnector connector) {
+ // Caption not supported
+ }
+
+ @Override
+ public void onConnectorHierarchyChange(
+ ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
+ Connector stateChild = getState().child;
+ if (stateChild == null) {
+ if (getChildComponents().size() != 0) {
+ throw new IllegalStateException(
+ "Hierarchy has child but state has not");
+ } else {
+ getWidget().setWidget(null);
+ }
+ } else {
+ if (getChildComponents().size() != 1
+ || getChildComponents().get(0) != stateChild) {
+ throw new IllegalStateException(
+ "State has child but hierarchy has not");
+ } else {
+ getWidget().setWidget(getChildComponents().get(0).getWidget());
+ }
+ }
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java
new file mode 100644
index 0000000000..9dbededb50
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/UseStateFromHierachyChangeConnectorState.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2012 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;
+
+import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.Connector;
+
+public class UseStateFromHierachyChangeConnectorState extends
+ AbstractComponentState {
+ public Connector child;
+}