aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorMikael Grankvist <mgrankvi@vaadin.com>2014-07-01 14:11:05 +0300
committerVaadin Code Review <review@vaadin.com>2014-08-07 06:32:16 +0000
commit75f42d32229c2a4c5198a8d2b5ae5b2d90a7f8ff (patch)
treed946f20d5e405819ef3cc8bf7141c6cd75f22a8d /uitest
parentf5afdd6d4acae5d9bccf47ebc320787b53659cce (diff)
downloadvaadin-framework-75f42d32229c2a4c5198a8d2b5ae5b2d90a7f8ff.tar.gz
vaadin-framework-75f42d32229c2a4c5198a8d2b5ae5b2d90a7f8ff.zip
DelegateToWidget will now be run even for parent states for extending
states (#14059) Updated the code to encompass Leif's suggestion. Change-Id: I70c0a4a93b9fe9ee8b2c458d666a1fec791f20b4
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java15
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaState.java7
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java19
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaState.java11
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java16
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendants.java67
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java50
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/server/SuperTextArea.java16
8 files changed, 201 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java
new file mode 100644
index 0000000000..b9037208f9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaConnector.java
@@ -0,0 +1,15 @@
+package com.vaadin.tests.widgetset.client.superText;
+
+import com.vaadin.client.ui.textarea.TextAreaConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.widgetset.server.ExtraSuperTextArea;
+
+@Connect(ExtraSuperTextArea.class)
+public class ExtraSuperTextAreaConnector extends TextAreaConnector {
+
+ // @DelegateToWidget will not work with overridden state
+ @Override
+ public ExtraSuperTextAreaState getState() {
+ return (ExtraSuperTextAreaState) super.getState();
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaState.java b/uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaState.java
new file mode 100644
index 0000000000..44456b27ba
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/superText/ExtraSuperTextAreaState.java
@@ -0,0 +1,7 @@
+package com.vaadin.tests.widgetset.client.superText;
+
+import com.vaadin.shared.ui.textarea.TextAreaState;
+
+public class ExtraSuperTextAreaState extends TextAreaState {
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java
new file mode 100644
index 0000000000..fda1fc6f0a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaConnector.java
@@ -0,0 +1,19 @@
+package com.vaadin.tests.widgetset.client.superText;
+
+import com.vaadin.client.ui.textarea.TextAreaConnector;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.tests.widgetset.server.SuperTextArea;
+
+/**
+ * @author artamonov
+ * @version $Id$
+ */
+@Connect(SuperTextArea.class)
+public class SuperTextAreaConnector extends TextAreaConnector {
+
+ // @DelegateToWidget will not work with overridden state
+ @Override
+ public SuperTextAreaState getState() {
+ return (SuperTextAreaState) super.getState();
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaState.java b/uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaState.java
new file mode 100644
index 0000000000..005075429c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/client/superText/SuperTextAreaState.java
@@ -0,0 +1,11 @@
+package com.vaadin.tests.widgetset.client.superText;
+
+import com.vaadin.shared.ui.textarea.TextAreaState;
+
+/**
+ * @author artamonov
+ * @version $Id$
+ */
+public class SuperTextAreaState extends TextAreaState {
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java b/uitest/src/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java
new file mode 100644
index 0000000000..b741c099b5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/ExtraSuperTextArea.java
@@ -0,0 +1,16 @@
+package com.vaadin.tests.widgetset.server;
+
+import com.vaadin.tests.widgetset.client.superText.SuperTextAreaState;
+import com.vaadin.ui.TextArea;
+
+/**
+ * @author artamonov
+ * @version $Id$
+ */
+public class ExtraSuperTextArea extends TextArea {
+
+ @Override
+ public SuperTextAreaState getState() {
+ return (SuperTextAreaState) super.getState();
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendants.java b/uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendants.java
new file mode 100644
index 0000000000..aadabb3fcc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendants.java
@@ -0,0 +1,67 @@
+/*
+ * 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.server;
+
+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.TextArea;
+
+/**
+ * UI for testing that @DelegateToWidget works on derived widget states.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+@Widgetset(TestingWidgetSet.NAME)
+public class OverriddenDecendants extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ TextArea normalTextArea = new TextArea();
+ normalTextArea.setRows(10);
+ normalTextArea.setWordwrap(true);
+
+ getLayout().addComponent(normalTextArea);
+
+ // @DelegateToWidget will not work with overridden state in connector
+ SuperTextArea superTextArea = new SuperTextArea();
+ superTextArea.setRows(10);
+ superTextArea.setWordwrap(true);
+
+ getLayout().addComponent(superTextArea);
+
+ // @DelegateToWidget will not work with overridden state in connector
+ ExtraSuperTextArea extraSuperTextArea = new ExtraSuperTextArea();
+ extraSuperTextArea.setRows(10);
+ extraSuperTextArea.setWordwrap(true);
+
+ getLayout().addComponent(extraSuperTextArea);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "@DelegateToWidget does not work for widget descendants with overridden getState";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14059;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java b/uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.java
new file mode 100644
index 0000000000..aa29284010
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/OverriddenDecendantsTest.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.widgetset.server;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.TextAreaElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Class for unit testing that @DelegateToWidget works on derived widget states.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class OverriddenDecendantsTest extends MultiBrowserTest {
+
+ @Test
+ public void allExtendingFieldsShouldGetRowsFromTextAreaStateAnnotation()
+ throws InterruptedException {
+ openTestURL();
+
+ List<TextAreaElement> textAreas = $(TextAreaElement.class).all();
+
+ assertEquals("Did not contain all 3 text areas", 3, textAreas.size());
+
+ for (TextAreaElement area : textAreas) {
+ assertEquals("Text area was missing rows", "10",
+ area.getAttribute("rows"));
+ }
+
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/widgetset/server/SuperTextArea.java b/uitest/src/com/vaadin/tests/widgetset/server/SuperTextArea.java
new file mode 100644
index 0000000000..6e73915e44
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/widgetset/server/SuperTextArea.java
@@ -0,0 +1,16 @@
+package com.vaadin.tests.widgetset.server;
+
+import com.vaadin.tests.widgetset.client.superText.SuperTextAreaState;
+import com.vaadin.ui.TextArea;
+
+/**
+ * @author artamonov
+ * @version $Id$
+ */
+public class SuperTextArea extends TextArea {
+
+ @Override
+ public SuperTextAreaState getState() {
+ return (SuperTextAreaState) super.getState();
+ }
+} \ No newline at end of file