summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/application
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/application
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/application')
-rw-r--r--uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java72
-rw-r--r--uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.html57
-rw-r--r--uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java105
-rw-r--r--uitest/src/com/vaadin/tests/application/RefreshStatePreserve.html52
-rw-r--r--uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java45
-rw-r--r--uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html36
-rw-r--r--uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java70
-rw-r--r--uitest/src/com/vaadin/tests/application/ThreadLocalInstances.html111
-rw-r--r--uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java113
-rw-r--r--uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.html31
-rw-r--r--uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java48
-rw-r--r--uitest/src/com/vaadin/tests/application/WebBrowserTest.html44
-rw-r--r--uitest/src/com/vaadin/tests/application/WebBrowserTest.java99
13 files changed, 883 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java b/uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java
new file mode 100644
index 0000000000..233da9722e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java
@@ -0,0 +1,72 @@
+package com.vaadin.tests.application;
+
+import com.vaadin.Application;
+import com.vaadin.server.WebApplicationContext;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class ApplicationCloseTest extends TestBase {
+
+ private String memoryConsumer;
+
+ @Override
+ protected void setup() {
+ Label applications = new Label("Applications in session: <br/>",
+ ContentMode.XHTML);
+ for (Application a : ((WebApplicationContext) getContext())
+ .getApplications()) {
+ applications.setValue(applications.getValue() + "App: " + a
+ + "<br/>");
+ }
+ applications.setValue(applications.getValue() + "<br/><br/>");
+
+ addComponent(applications);
+ Label thisApp = new Label("This applications: " + this);
+ Button close = new Button("Close this", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ event.getButton().getApplication().close();
+ }
+ });
+
+ StringBuilder sb = new StringBuilder();
+
+ // 100 bytes
+ String str = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
+
+ int MB = 5;
+ for (int i = 0; i < MB * 10000; i++) {
+ sb.append(str);
+ }
+
+ memoryConsumer = sb.toString();
+ long totalUsage = Runtime.getRuntime().totalMemory();
+ String totalUsageString = totalUsage / 1000 / 1000 + "MiB";
+ Label memoryUsage = new Label(
+ "Using about "
+ + memoryConsumer.length()
+ / 1000
+ / 1000
+ + "MiB memory for this application.<br/>Total memory usage reported as "
+ + totalUsageString + "<br/>", ContentMode.XHTML);
+
+ addComponent(thisApp);
+ addComponent(memoryUsage);
+ addComponent(close);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click close to close the application and open a new one";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3732;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.html b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.html
new file mode 100644
index 0000000000..ee200d7f5c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.html
@@ -0,0 +1,57 @@
+<?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="http://arturwin.office.itmill.com:8888/" />
+<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.ErrorInUnloadEvent?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Suser</td>
+ <td>66,14</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Suser</td>
+ <td>a</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd</td>
+ <td>73,16</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd</td>
+ <td>d</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.ErrorInUnloadEvent</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationErrorInUnloadEvent::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+ <td>...Title...</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java
new file mode 100644
index 0000000000..d7e9155ded
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java
@@ -0,0 +1,105 @@
+package com.vaadin.tests.application;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PasswordField;
+import com.vaadin.ui.UI.LegacyWindow;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class ErrorInUnloadEvent extends AbstractTestCase {
+
+ private LegacyWindow mainWindow;
+
+ @Override
+ public void init() {
+ if (getUser() == null) {
+ showLoginWindow();
+ } else {
+ showMainWindow();
+ }
+ }
+
+ private void showLoginWindow() {
+ if (mainWindow == null) {
+ mainWindow = new LegacyWindow();
+ setMainWindow(mainWindow);
+ } else {
+ mainWindow.removeAllComponents();
+ }
+ mainWindow.setCaption("Please login");
+
+ FormLayout formLayout = new FormLayout();
+ final TextField userField = new TextField("Username");
+ userField.setId("user");
+ final PasswordField passwordField = new PasswordField("Password");
+ passwordField.setId("pwd");
+ Button login = new Button("login");
+ login.setId("loginButton");
+ login.setClickShortcut(KeyCode.ENTER);
+ formLayout.addComponent(userField);
+ formLayout.addComponent(passwordField);
+ formLayout.addComponent(login);
+ mainWindow.setContent(formLayout);
+
+ login.addListener(new ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ String username = userField.getValue();
+ String password = passwordField.getValue();
+
+ setUser(username);
+ showMainWindow();
+ }
+ });
+ }
+
+ private void showMainWindow() {
+ if (mainWindow == null) {
+ mainWindow = new LegacyWindow();
+ setMainWindow(mainWindow);
+ } else {
+ mainWindow.removeAllComponents();
+ }
+ VerticalLayout root = new VerticalLayout();
+ root.addComponent(createHeader());
+
+ mainWindow.addComponent(root);
+ }
+
+ private Component createHeader() {
+ HorizontalLayout header = new HorizontalLayout();
+ header.addStyleName("header-background");
+ Label title = new Label("...Title...");
+ title.addStyleName("header-title");
+ header.addComponent(title);
+ Button logout = new Button("Logout");
+ logout.addListener(new ClickListener() {
+ @Override
+ public void buttonClick(final ClickEvent event) {
+ setUser(null);
+ showLoginWindow();
+ }
+
+ });
+ header.addComponent(logout);
+ return header;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Enter a text in the password field and press enter. Then reload the page. No error message should be printed about ignoring a variable change.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6316;
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.html b/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.html
new file mode 100644
index 0000000000..d48ab220b5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.html
@@ -0,0 +1,52 @@
+<?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.RefreshStatePreserve?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationRefreshStatePreserve::/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
+ <td>Root id: 0</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.RefreshStatePreserve</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationRefreshStatePreserve::/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
+ <td>Root id: 0</td>
+</tr>
+<tr>
+ <td>runScript</td>
+ <td>history.back()</td>
+ <td></td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td></td>
+ <td>1000</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationRefreshStatePreserve::/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
+ <td>Root id: 0</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java b/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java
new file mode 100644
index 0000000000..3013659ed7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java
@@ -0,0 +1,45 @@
+package com.vaadin.tests.application;
+
+import com.vaadin.Application;
+import com.vaadin.UIRequiresMoreInformationException;
+import com.vaadin.server.AbstractUIProvider;
+import com.vaadin.server.WrappedRequest;
+import com.vaadin.tests.components.AbstractTestApplication;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+
+public class RefreshStatePreserve extends AbstractTestApplication {
+ public static class RefreshStateUI extends UI {
+ @Override
+ public void init(WrappedRequest request) {
+ getContent().addComponent(
+ new Label("window.name: "
+ + request.getBrowserDetails().getWindowName()));
+ getContent().addComponent(new Label("UI id: " + getUIId()));
+ }
+ }
+
+ @Override
+ public void init() {
+ super.init();
+ setUiPreserved(true);
+ addUIProvider(new AbstractUIProvider() {
+ @Override
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request)
+ throws UIRequiresMoreInformationException {
+ return RefreshStateUI.class;
+ }
+ });
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Refreshing the browser window should preserve the state";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(8068);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html
new file mode 100644
index 0000000000..f20967c8de
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.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>TabSheetWithDisappearingContent</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TabSheetWithDisappearingContent</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.TerminalErrorNotification?restartApplication&amp;debug</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationTerminalErrorNotification::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementPresent</td>
+ <td>vaadin=runcomvaadintestsapplicationTerminalErrorNotification::Root/VNotification[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationTerminalErrorNotification::Root/VNotification[0]/HTML[0]/domChild[0]</td>
+ <td>Got an exception: You asked for it</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java
new file mode 100644
index 0000000000..0dcf0a6fa8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java
@@ -0,0 +1,70 @@
+/*
+ * 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.application;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.UI;
+
+public class TerminalErrorNotification extends TestBase {
+
+ @Override
+ protected void setup() {
+ Button button = new Button("Throw exception",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ throw new RuntimeException("You asked for it");
+ }
+ });
+
+ addComponent(button);
+ }
+
+ @Override
+ public void terminalError(com.vaadin.server.Terminal.ErrorEvent event) {
+ event.getThrowable().printStackTrace();
+
+ UI mainWindow = getMainWindow();
+ if (mainWindow != null) {
+ Throwable throwable = event.getThrowable();
+
+ // Find the root cause
+ while (throwable.getCause() != null) {
+ throwable = throwable.getCause();
+ }
+
+ Notification.show("Got an exception: " + throwable.getMessage(),
+ Notification.TYPE_ERROR_MESSAGE);
+ } else {
+ System.out.println("No main window found");
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Showing a notification in the terminalError method should make the notification appear in the browser.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(8778);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.html b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.html
new file mode 100644
index 0000000000..35657c73fc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.html
@@ -0,0 +1,111 @@
+<?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.ThreadLocalInstances?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementHeight</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::/VVerticalLayout[0]/ChildComponentContainer[1]/VEmbedded[0]/domChild[0]</td>
+ <td>11</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_15</td>
+ <td>1. null app in class init</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_14</td>
+ <td>2. null root in class init</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_13</td>
+ <td>3. null app in app constructor</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_12</td>
+ <td>4. null root in app constructor</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_11</td>
+ <td>5. this app in app init</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_10</td>
+ <td>6. null root in app init</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_9</td>
+ <td>7. this app in root init</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_8</td>
+ <td>8. this root in root init</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_7</td>
+ <td>9. this app in root paint</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_6</td>
+ <td>10. this root in root paint</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_5</td>
+ <td>11. null app in background thread</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_4</td>
+ <td>12. null root in background thread</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_3</td>
+ <td>13. this app in resource handler</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_2</td>
+ <td>14. null root in resource handler</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_1</td>
+ <td>15. this app in button listener</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationThreadLocalInstances::PID_SLog_row_0</td>
+ <td>16. this root in button listener</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java
new file mode 100644
index 0000000000..0e7dd1b242
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java
@@ -0,0 +1,113 @@
+package com.vaadin.tests.application;
+
+import com.vaadin.Application;
+import com.vaadin.UIRequiresMoreInformationException;
+import com.vaadin.server.DownloadStream;
+import com.vaadin.server.PaintException;
+import com.vaadin.server.WrappedRequest;
+import com.vaadin.tests.components.AbstractTestApplication;
+import com.vaadin.tests.integration.FlagSeResource;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.UI;
+
+public class ThreadLocalInstances extends AbstractTestApplication {
+ private static final Application staticInitApplication = Application
+ .getCurrent();
+ private static final UI staticInitRoot = UI.getCurrent();
+
+ private final UI mainWindow = new UI() {
+ boolean paintReported = false;
+
+ @Override
+ protected void init(WrappedRequest request) {
+ reportCurrentStatus("root init");
+ }
+
+ @Override
+ public void paintContent(com.vaadin.server.PaintTarget target)
+ throws PaintException {
+ if (!paintReported) {
+ reportCurrentStatus("root paint");
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ synchronized (ThreadLocalInstances.this) {
+ reportCurrentStatus("background thread");
+ }
+ }
+ };
+ thread.start();
+ paintReported = true;
+ }
+ super.paintContent(target);
+ }
+ };
+
+ private final FlagSeResource resource = new FlagSeResource() {
+ @Override
+ public DownloadStream getStream() {
+ reportCurrentStatus("resource handler");
+ return super.getStream();
+ }
+ };
+
+ private final Log log = new Log(16);
+
+ public ThreadLocalInstances() {
+ mainWindow.addComponent(log);
+ mainWindow.addComponent(new Embedded("Icon", resource));
+ mainWindow.addComponent(new Button("Sync", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ reportCurrentStatus("button listener");
+ }
+ }));
+
+ reportStatus("class init", staticInitApplication, staticInitRoot);
+ reportCurrentStatus("app constructor");
+ }
+
+ @Override
+ public void init() {
+ reportCurrentStatus("app init");
+ }
+
+ @Override
+ protected UI getUI(WrappedRequest request)
+ throws UIRequiresMoreInformationException {
+ return mainWindow;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Tests the precence of Application.getCurrentApplication() and UI.getCurrentRoot() from different contexts";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(7895);
+ }
+
+ private void reportCurrentStatus(String phase) {
+ reportStatus(phase, Application.getCurrent(), UI.getCurrent());
+ }
+
+ private void reportStatus(String phase, Application application, UI uI) {
+ log.log(getState(application, this) + " app in " + phase);
+ log.log(getState(uI, mainWindow) + " root in " + phase);
+ }
+
+ private static String getState(Object value, Object reference) {
+ if (value == null) {
+ return "null";
+ } else if (value == reference) {
+ return "this";
+ } else {
+ return value.toString();
+ }
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.html b/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.html
new file mode 100644
index 0000000000..3c59c7a953
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.html
@@ -0,0 +1,31 @@
+<?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.WebBrowserSizeTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserSizeTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>size</td>
+</tr>
+</tbody></table>
+</body>
+</html> \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java b/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java
new file mode 100644
index 0000000000..817acf20b5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java
@@ -0,0 +1,48 @@
+package com.vaadin.tests.application;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class WebBrowserSizeTest extends TestBase {
+
+ @Override
+ protected void setup() {
+
+ final Label screenSizeLabel = new Label("n/a");
+ screenSizeLabel.setCaption("Screen size");
+
+ final Label browserSizeLabel = new Label("n/a");
+ browserSizeLabel.setCaption("Client (browser window) size");
+
+ final Button update = new Button("Refresh", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x "
+ + getBrowser().getScreenHeight());
+ browserSizeLabel.setValue(getMainWindow()
+ .getBrowserWindowWidth()
+ + " x "
+ + getMainWindow().getBrowserWindowHeight());
+ }
+ });
+
+ addComponent(update);
+ addComponent(screenSizeLabel);
+ addComponent(browserSizeLabel);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5655;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserTest.html b/uitest/src/com/vaadin/tests/application/WebBrowserTest.html
new file mode 100644
index 0000000000..f04dd564bf
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/WebBrowserTest.html
@@ -0,0 +1,44 @@
+<?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.WebBrowserTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<!-- Raw offset -->
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
+ <td>7200000</td>
+</tr>
+<!-- offset to Helsinki -->
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0]</td>
+ <td>0</td>
+</tr>
+<!-- in Helsinki? -->
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0]</td>
+ <td>Yes</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserTest.java b/uitest/src/com/vaadin/tests/application/WebBrowserTest.java
new file mode 100644
index 0000000000..004c8f1c91
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/WebBrowserTest.java
@@ -0,0 +1,99 @@
+package com.vaadin.tests.application;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.TimeZone;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class WebBrowserTest extends TestBase {
+
+ @Override
+ protected void setup() {
+
+ final Label offsetLabel = new Label("n/a");
+ offsetLabel.setCaption("Browser offset");
+
+ final Label rawOffsetLabel = new Label("n/a");
+ rawOffsetLabel.setCaption("Browser raw offset");
+
+ final Label dstDiffLabel = new Label("n/a");
+ dstDiffLabel.setCaption("Difference between raw offset and DST");
+
+ final Label dstInEffectLabel = new Label("n/a");
+ dstInEffectLabel.setCaption("Is DST currently active?");
+
+ final Label curDateLabel = new Label("n/a");
+ curDateLabel.setCaption("Current date in the browser");
+
+ final Label diffLabel = new Label("n/a");
+ diffLabel.setCaption("Browser to Europe/Helsinki offset difference");
+
+ final Label containsLabel = new Label("n/a");
+ containsLabel.setCaption("Browser could be in Helsinki");
+
+ final Button update = new Button("Get TimeZone from browser",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ TimeZone hkiTZ = TimeZone
+ .getTimeZone("Europe/Helsinki");
+ int hkiOffset = hkiTZ.getOffset(new Date().getTime());
+
+ int browserOffset = getBrowser().getTimezoneOffset();
+ int browserRawOffset = getBrowser()
+ .getRawTimezoneOffset();
+ String[] tzs = TimeZone
+ .getAvailableIDs(browserRawOffset);
+
+ boolean contains = Arrays.asList(tzs).contains(
+ hkiTZ.getID());
+
+ offsetLabel.setValue(String.valueOf(browserOffset));
+
+ rawOffsetLabel.setValue(String
+ .valueOf(browserRawOffset));
+
+ diffLabel.setValue(String.valueOf(browserOffset
+ - hkiOffset));
+
+ containsLabel.setValue(contains ? "Yes" : "No");
+
+ dstDiffLabel.setValue(String.valueOf(getBrowser()
+ .getDSTSavings()));
+
+ dstInEffectLabel
+ .setValue(getBrowser().isDSTInEffect() ? "Yes"
+ : "No");
+
+ curDateLabel.setValue(getBrowser().getCurrentDate()
+ .toString());
+
+ }
+ });
+
+ addComponent(update);
+ addComponent(offsetLabel);
+ addComponent(rawOffsetLabel);
+ addComponent(dstDiffLabel);
+ addComponent(dstInEffectLabel);
+ addComponent(curDateLabel);
+ addComponent(diffLabel);
+ addComponent(containsLabel);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Verifies that browser TimeZone offset works - should be same as server in our case (NOTE assumes server+browser in same TZ)";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6691;
+ }
+
+}