summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/vaadincontext
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-11-20 16:53:49 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-21 13:41:46 +0000
commitfeac70070091a3d823632a7396ec4eef0886f5b2 (patch)
tree6f30cfdeb85bc7969d5f4c98e425e0b482d7e65c /uitest/src/com/vaadin/tests/vaadincontext
parent29ea66b5bad701db2a3f6e2c67a143678d1dd52a (diff)
downloadvaadin-framework-feac70070091a3d823632a7396ec4eef0886f5b2.tar.gz
vaadin-framework-feac70070091a3d823632a7396ec4eef0886f5b2.zip
Remove AddonContext (#10254)
Change-Id: I12d3075a4808b004d7b891d1c4092131fa7cb1a2
Diffstat (limited to 'uitest/src/com/vaadin/tests/vaadincontext')
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html10
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java53
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java65
3 files changed, 62 insertions, 66 deletions
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html
index e6fafb14fa..83db83b5f7 100644
--- a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html
+++ b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html
@@ -17,6 +17,16 @@
<td></td>
</tr>
<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsvaadincontextBootstrapModifyUI::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.vaadincontext.BootstrapModifyUI</td>
+ <td></td>
+</tr>
+<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestsvaadincontextBootstrapModifyUI::/VVerticalLayout[0]/VLabel[0]</td>
<td>There should be two additional divs in the HTML of the bootstrap page for this UI</td>
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
index 35f7aeb044..512d89a381 100644
--- a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
+++ b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
@@ -16,15 +16,66 @@
package com.vaadin.tests.vaadincontext;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.server.BootstrapFragmentResponse;
+import com.vaadin.server.BootstrapListener;
+import com.vaadin.server.BootstrapPageResponse;
+import com.vaadin.server.BootstrapResponse;
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.UI;
public class BootstrapModifyUI extends AbstractTestUI {
+ private static final String INSTALLED_ATRIBUTE_NAME = BootstrapModifyUI.class
+ .getName() + ".installed";
@Override
protected void setup(VaadinRequest request) {
- // TODO Auto-generated method stub
+ Button c = new Button("Add bootstrap listener",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ getSession().addBootstrapListener(
+ createBootstrapListener());
+ event.getButton().setEnabled(false);
+ getSession().setAttribute(INSTALLED_ATRIBUTE_NAME,
+ Boolean.TRUE);
+ }
+ });
+ addComponent(c);
+ c.setEnabled(getSession().getAttribute(INSTALLED_ATRIBUTE_NAME) == null);
+ }
+
+ private static BootstrapListener createBootstrapListener() {
+ return new BootstrapListener() {
+ @Override
+ public void modifyBootstrapFragment(
+ BootstrapFragmentResponse response) {
+ if (shouldModify(response)) {
+ Element heading = new Element(Tag.valueOf("div"), "")
+ .text("Added by modifyBootstrapFragment");
+ response.getFragmentNodes().add(0, heading);
+ }
+ }
+
+ private boolean shouldModify(BootstrapResponse response) {
+ Class<? extends UI> uiClass = response.getUiClass();
+ boolean shouldModify = uiClass == BootstrapModifyUI.class;
+ return shouldModify;
+ }
+ @Override
+ public void modifyBootstrapPage(BootstrapPageResponse response) {
+ if (shouldModify(response)) {
+ response.getDocument().body().child(0)
+ .before("<div>Added by modifyBootstrapPage</div>");
+ }
+ }
+ };
}
@Override
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
deleted file mode 100644
index 87a0f5fa51..0000000000
--- a/uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.vaadincontext;
-
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.server.AddonContextEvent;
-import com.vaadin.server.AddonContextListener;
-import com.vaadin.server.BootstrapFragmentResponse;
-import com.vaadin.server.BootstrapListener;
-import com.vaadin.server.BootstrapPageResponse;
-import com.vaadin.server.BootstrapResponse;
-import com.vaadin.ui.UI;
-
-public class TestAddonContextListener implements AddonContextListener {
- @Override
- public void contextCreated(AddonContextEvent event) {
- event.getAddonContext().addBootstrapListener(new BootstrapListener() {
- @Override
- public void modifyBootstrapFragment(
- BootstrapFragmentResponse response) {
- if (shouldModify(response)) {
- Element heading = new Element(Tag.valueOf("div"), "")
- .text("Added by modifyBootstrapFragment");
- response.getFragmentNodes().add(0, heading);
- }
- }
-
- private boolean shouldModify(BootstrapResponse response) {
- Class<? extends UI> uiClass = response.getUiClass();
- boolean shouldModify = uiClass == BootstrapModifyUI.class;
- return shouldModify;
- }
-
- @Override
- public void modifyBootstrapPage(BootstrapPageResponse response) {
- if (shouldModify(response)) {
- response.getDocument().body().child(0)
- .before("<div>Added by modifyBootstrapPage</div>");
- }
- }
- });
- }
-
- @Override
- public void contextDestroyed(AddonContextEvent event) {
- // Nothing to do
- }
-
-}