aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/application
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-07-22 09:14:30 +0300
committerVaadin Code Review <review@vaadin.com>2013-07-31 14:24:40 +0000
commitbd923f394c7b60ea912558201bf5afd710285722 (patch)
tree8ba658c183e9d34b63aa272f414f481904808e7e /uitest/src/com/vaadin/tests/application
parent6a6952749924d4aaa12c6f1354ed94d388b85e64 (diff)
downloadvaadin-framework-bd923f394c7b60ea912558201bf5afd710285722.tar.gz
vaadin-framework-bd923f394c7b60ea912558201bf5afd710285722.zip
Detach previous UI with the same window.name (#10338, #12255)
Change-Id: I15234985f1591d6af383c6e014679762619d5000
Diffstat (limited to 'uitest/src/com/vaadin/tests/application')
-rw-r--r--uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html77
-rw-r--r--uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java80
2 files changed, 157 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html
new file mode 100644
index 0000000000..038283324d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html
@@ -0,0 +1,77 @@
+<?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.application.DetachOldUIOnReload?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
+ <td>This is UI 0</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.DetachOldUIOnReload</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td>
+ <td>1. UI 0 has been detached</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
+ <td>This is UI 1</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td>
+ <td>2. UI 1 has been detached</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
+ <td>This is UI 2</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.DetachOldUIOnReload</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td>
+ <td>3. UI 2 has been detached</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
+ <td>This is UI 3</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java
new file mode 100644
index 0000000000..7104146203
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2000-2013 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.application;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class DetachOldUIOnReload extends AbstractTestUIWithLog {
+ private static final String PERSISTENT_MESSAGES_ATTRIBUTE = DetachOldUIOnReload.class
+ .getName() + ".sessionMessages";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ for (String message : getSessionMessages(false)) {
+ log(message);
+ }
+
+ addComponent(new Label("This is UI " + getUIId()));
+ addComponent(new Button("Reload page", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ getPage().reload();
+ }
+ }));
+ }
+
+ private List<String> getSessionMessages(boolean storeIfNeeded) {
+ List<String> messages = (List<String>) getSession().getAttribute(
+ PERSISTENT_MESSAGES_ATTRIBUTE);
+ if (messages == null) {
+ messages = new ArrayList<String>();
+ if (storeIfNeeded) {
+ getSession().setAttribute(PERSISTENT_MESSAGES_ATTRIBUTE,
+ messages);
+ }
+ }
+ return messages;
+ }
+
+ private void logToSession(String message) {
+ getSessionMessages(true).add(message);
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ logToSession("UI " + getUIId() + " has been detached");
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Tests that the previous UI gets cleaned immediately when refreshing.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(10338);
+ }
+
+}