summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/vaadincontext
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-08-30 17:24:36 +0300
committerArtur Signell <artur@vaadin.com>2012-08-30 17:24:36 +0300
commit7b25b3886ea95bc6495506fbe9472e45fcbde684 (patch)
tree0b93cb65dab437feb46720659a63b8f1ef48f7f4 /uitest/src/com/vaadin/tests/vaadincontext
parent8941056349e302e687e40e94c13709e75f256d73 (diff)
downloadvaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.tar.gz
vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.zip
Renamed tests -> uitest and tests/testbench -> uitest/src (#9299)
Diffstat (limited to 'uitest/src/com/vaadin/tests/vaadincontext')
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html36
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java40
-rw-r--r--uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java66
3 files changed, 142 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html
new file mode 100644
index 0000000000..e6fafb14fa
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html
@@ -0,0 +1,36 @@
+<?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.vaadincontext.BootstrapModifyUI?restartApplication</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>
+</tr>
+<tr>
+ <td>assertText</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>
+</html>
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
new file mode 100644
index 0000000000..bc3d88e2bb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java
@@ -0,0 +1,40 @@
+/*
+ * 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 com.vaadin.server.WrappedRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+
+public class BootstrapModifyUI extends AbstractTestUI {
+
+ @Override
+ protected void setup(WrappedRequest request) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "There should be two additional divs in the HTML of the bootstrap page for this UI";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(9274);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
new file mode 100644
index 0000000000..9f3019b21c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
@@ -0,0 +1,66 @@
+/*
+ * 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) {
+ UI uI = response.getUI();
+ boolean shouldModify = uI != null
+ && uI.getClass() == 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 contextDestoryed(AddonContextEvent event) {
+ // Nothing to do
+ }
+
+}