diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-13 13:58:22 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-13 15:03:21 +0300 |
commit | c4d3ca692e8086ce93540b26bbfd41faa9510d07 (patch) | |
tree | 394da4ff6acb1cb7aebb6b1c28f4ea509e7cf9ba /tests | |
parent | 7d2fd844a14b3db1bce9befe255e041ce7193536 (diff) | |
download | vaadin-framework-c4d3ca692e8086ce93540b26bbfd41faa9510d07.tar.gz vaadin-framework-c4d3ca692e8086ce93540b26bbfd41faa9510d07.zip |
Refactor to have separate BootstrapListener methods (#9274)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html | 9 | ||||
-rw-r--r-- | tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java | 29 |
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>"); } } }); |