summaryrefslogtreecommitdiffstats
path: root/tests/testbench/com
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testbench/com')
-rw-r--r--tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html9
-rw-r--r--tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java29
2 files changed, 32 insertions, 6 deletions
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html
index d5ab5af108..84c02254b4 100644
--- a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html
+++ b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html
@@ -23,8 +23,13 @@
</tr>
<tr>
<td>assertText</td>
- <td>//h1</td>
- <td>This is a heading</td>
+ <td>//div[1]</td>
+ <td>Added by modifyBootstrapPage</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>//div[2]</td>
+ <td>Added by modifyBootstrapFragment</td>
</tr>
</tbody></table>
</body>
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java
index fa2767a023..9d1fc6b6c3 100644
--- a/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java
+++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java
@@ -4,7 +4,12 @@
package com.vaadin.tests.vaadincontext;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.terminal.gwt.server.BootstrapFragmentResponse;
import com.vaadin.terminal.gwt.server.BootstrapListener;
+import com.vaadin.terminal.gwt.server.BootstrapPageResponse;
import com.vaadin.terminal.gwt.server.BootstrapResponse;
import com.vaadin.terminal.gwt.server.VaadinContextEvent;
import com.vaadin.terminal.gwt.server.VaadinContextListener;
@@ -15,11 +20,27 @@ public class TestVaadinContextListener implements VaadinContextListener {
public void contextCreated(VaadinContextEvent event) {
event.getVaadinContext().addBootstrapListener(new BootstrapListener() {
@Override
- public void modifyBootstrap(BootstrapResponse response) {
+ 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) {
Root root = response.getRoot();
- if (root != null && root.getClass() == BoostrapModifyRoot.class) {
- response.getApplicationTag().before(
- "<h1>This is a heading</h1>");
+ boolean shouldModify = root != null
+ && root.getClass() == BoostrapModifyRoot.class;
+ return shouldModify;
+ }
+
+ @Override
+ public void modifyBootstrapPage(BootstrapPageResponse response) {
+ if (shouldModify(response)) {
+ response.getDocument().body().child(0)
+ .before("<div>Added by modifyBootstrapPage</div>");
}
}
});