summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-08-24 11:25:05 +0300
committerLeif Åstrand <leif@vaadin.com>2012-08-24 11:25:26 +0300
commit38ffd4a097094a01c35fbd5b79563e6c8ea02e92 (patch)
tree90b07bee9ff39dfcebe51909fb63bd1c782611dd /tests
parent52986fdf881260994e5465012af2afd80447b8b6 (diff)
downloadvaadin-framework-38ffd4a097094a01c35fbd5b79563e6c8ea02e92.tar.gz
vaadin-framework-38ffd4a097094a01c35fbd5b79563e6c8ea02e92.zip
Make it possible to delegate state changes to widget (#9297)
Diffstat (limited to 'tests')
-rw-r--r--tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html26
-rw-r--r--tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java42
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java21
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java34
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java50
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java50
-rw-r--r--tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java35
7 files changed, 258 insertions, 0 deletions
diff --git a/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html
new file mode 100644
index 0000000000..12228eb9f0
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.serialization.DelegateToWidgetTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsserializationDelegateToWidgetTest::/VVerticalLayout[0]/VVerticalLayout[0]/DelegateWidget[0]</td>
+ <td>My String<br />42<br />true<br />3.141592653589793</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java
new file mode 100644
index 0000000000..54170c880f
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011 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.serialization;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.tests.components.AbstractTestRoot;
+import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent;
+
+@Widgetset(TestingWidgetSet.NAME)
+public class DelegateToWidgetTest extends AbstractTestRoot {
+ @Override
+ protected void setup(WrappedRequest request) {
+ addComponent(new DelegateToWidgetComponent());
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Verifies that @DelegateToWidget has the desired effect";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(9297);
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java b/tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java
new file mode 100644
index 0000000000..0464a53a95
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2011 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;
+
+public class TestingWidgetSet {
+ public static final String NAME = "com.vaadin.tests.widgetset.TestingWidgetSet";
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java
new file mode 100644
index 0000000000..c711be232f
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011 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.ui.Connect;
+import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector;
+import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent;
+
+@Connect(DelegateToWidgetComponent.class)
+public class DelegateConnector extends AbstractComponentConnector {
+ @Override
+ public DelegateWidget getWidget() {
+ return (DelegateWidget) super.getWidget();
+ }
+
+ @Override
+ public DelegateState getState() {
+ return (DelegateState) super.getState();
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java
new file mode 100644
index 0000000000..e9ac8a1e61
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011 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.ComponentState;
+import com.vaadin.shared.annotations.DelegateToWidget;
+
+public class DelegateState extends ComponentState {
+ @DelegateToWidget
+ public String value1;
+
+ @DelegateToWidget("setValue2")
+ public int renamedValue2;
+
+ private Boolean value3;
+
+ private double renamedValue4;
+
+ @DelegateToWidget
+ public void setValue3(Boolean value3) {
+ this.value3 = value3;
+ }
+
+ public Boolean getValue3() {
+ return value3;
+ }
+
+ @DelegateToWidget("setValue4")
+ public void setRenamedValue4(double renamedValue4) {
+ this.renamedValue4 = renamedValue4;
+ }
+
+ public double getRenamedValue4() {
+ return renamedValue4;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java
new file mode 100644
index 0000000000..4776eced9a
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011 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.HTML;
+
+public class DelegateWidget extends HTML {
+ private String value1;
+ private int value2;
+ private Boolean value3;
+ private double value4;
+
+ public void setValue1(String value1) {
+ this.value1 = value1;
+ updateText();
+ }
+
+ public void setValue2(int value2) {
+ this.value2 = value2;
+ updateText();
+ }
+
+ public void setValue3(Boolean value3) {
+ this.value3 = value3;
+ updateText();
+ }
+
+ public void setValue4(double value4) {
+ this.value4 = value4;
+ }
+
+ private void updateText() {
+ setHTML(value1 + "<br />" + value2 + "<br />" + value3 + "<br />"
+ + value4 + "<br />");
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java b/tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java
new file mode 100644
index 0000000000..34c9699f7f
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011 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.tests.widgetset.client.DelegateState;
+import com.vaadin.ui.AbstractComponent;
+
+public class DelegateToWidgetComponent extends AbstractComponent {
+ public DelegateToWidgetComponent() {
+ DelegateState state = getState();
+ state.value1 = "My String";
+ state.renamedValue2 = 42;
+ state.setValue3(Boolean.TRUE);
+ state.setRenamedValue4(Math.PI);
+ }
+
+ @Override
+ protected DelegateState getState() {
+ return (DelegateState) super.getState();
+ }
+}