summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorMiki <miki@vaadin.com>2015-02-13 14:16:39 +0200
committerVaadin Code Review <review@vaadin.com>2015-02-18 07:45:18 +0000
commitd23382ad25b0a9f1ab1bf864f8fd3746e5b1c320 (patch)
tree108db32ae1e3059dcaae6a4db0fb31d2d0e7845e /uitest/src/com
parent1321b9f242d5355ed8d570b40d1f655a2b5ad14d (diff)
downloadvaadin-framework-d23382ad25b0a9f1ab1bf864f8fd3746e5b1c320.tar.gz
vaadin-framework-d23382ad25b0a9f1ab1bf864f8fd3746e5b1c320.zip
Migrated tb2 tests to tb4
DeploymentConfigurationTest OldUIOnReloadTest ErrorInUnloadEventTest VaadinSessionAttributeTest Change-Id: I2ccddf4d2bd01f4532dda79698e6be71b3b1a9f5
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java27
-rw-r--r--uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java53
-rw-r--r--uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java1
-rw-r--r--uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java85
-rw-r--r--uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java51
-rw-r--r--uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java36
6 files changed, 238 insertions, 15 deletions
diff --git a/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java b/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java
new file mode 100644
index 0000000000..9c95479bec
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java
@@ -0,0 +1,27 @@
+package com.vaadin.tests.application;
+
+import java.util.Properties;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+
+public class DeploymentConfiguration extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Properties params = getSession().getConfiguration().getInitParameters();
+ getLayout().setMargin(new MarginInfo(true, false, false, false));
+
+ for (Object key : params.keySet()) {
+ addComponent(new Label(key + ": "
+ + params.getProperty((String) key)));
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Init parameters:";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java b/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java
index 799622b31d..9a51980c9e 100644
--- a/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java
+++ b/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java
@@ -1,25 +1,48 @@
+/*
+ * Copyright 2000-2014 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.Properties;
+import static org.junit.Assert.assertTrue;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
-public class DeploymentConfigurationTest extends UI {
+import org.junit.Test;
- @Override
- protected void init(VaadinRequest request) {
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- setContent(layout);
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
- Properties params = getSession().getConfiguration().getInitParameters();
+public class DeploymentConfigurationTest extends MultiBrowserTest {
- for (Object key : params.keySet()) {
- layout.addComponent(new Label(key + ": "
- + params.getProperty((String) key)));
+ @Test
+ public void testParameters() {
+ openTestURL();
+ List<String> texts = new ArrayList<String>(Arrays.asList(
+ "Init parameters:", "legacyPropertyToString: false",
+ "closeIdleSessions: true", "productionMode: false",
+ "testParam: 42", "heartbeatInterval: 301",
+ "resourceCacheTime: 3601"));
+
+ for (LabelElement label : $(LabelElement.class).all()) {
+ assertTrue(label.getText() + " not found",
+ texts.contains(label.getText()));
+ texts.remove(label.getText());
}
+ assertTrue(texts.isEmpty());
}
+
}
diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java
index 8cb670c0fb..a7c9239fae 100644
--- a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java
+++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java
@@ -50,6 +50,7 @@ public class DetachOldUIOnReload extends AbstractTestUIWithLog {
}
private List<String> getSessionMessages(boolean storeIfNeeded) {
+ @SuppressWarnings("unchecked")
List<String> messages = (List<String>) getSession().getAttribute(
PERSISTENT_MESSAGES_ATTRIBUTE);
if (messages == null) {
diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java
new file mode 100644
index 0000000000..1e156c3e46
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2000-2014 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DetachOldUIOnReloadTest extends MultiBrowserTest {
+
+ private static final String RELOAD = "Reload page";
+ private static final String READ_LOG = "Read log messages from session";
+
+ @Test
+ public void testDetachesUIOnReload() throws InterruptedException {
+ openTestURL();
+ List<LabelElement> labels = $(LabelElement.class).all();
+ assertEquals("initial label incorrect", "This is UI 0",
+ lastLabelText(labels));
+
+ assertFalse("reloading button not found", $(ButtonElement.class)
+ .caption(RELOAD).all().isEmpty());
+
+ openTestURL();
+ click(READ_LOG);
+
+ checkLabels("first", 1);
+
+ click(RELOAD);
+ click(READ_LOG);
+
+ checkLabels("second", 2);
+
+ openTestURL();
+ click(READ_LOG);
+
+ checkLabels("third", 3);
+
+ // restarting reverts to 0
+ openTestURL("restartApplication");
+
+ checkLabels("final", 0);
+ }
+
+ private void checkLabels(String descriptor, int index) {
+ List<LabelElement> labels = $(LabelElement.class).all();
+ assertEquals(
+ String.format("label incorrect after %s reload", descriptor),
+ String.format("This is UI %s", index), lastLabelText(labels));
+ if (!"final".equals(descriptor)) {
+ assertEquals(String.format("log message incorrect after %s reload",
+ descriptor), String.format("%s. UI %s has been detached",
+ index, index - 1), labels.get(0).getText());
+ }
+ }
+
+ private String lastLabelText(List<LabelElement> labels) {
+ return labels.get(labels.size() - 1).getText();
+ }
+
+ private void click(String caption) {
+ $(ButtonElement.class).caption(caption).first().click();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java
new file mode 100644
index 0000000000..fa316c6749
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.PasswordFieldElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class ErrorInUnloadEventTest extends MultiBrowserTest {
+
+ @Test
+ public void testError() {
+ openTestURL();
+ TextFieldElement user = $(TextFieldElement.class).id("user");
+ user.focus();
+ user.sendKeys("a");
+ PasswordFieldElement pass = $(PasswordFieldElement.class).id("pwd");
+ pass.focus();
+ pass.sendKeys("d");
+ ButtonElement button = $(ButtonElement.class).id("loginButton");
+ button.click();
+
+ assertEquals("label is incorrect, error while loading page",
+ "...Title...", $(LabelElement.class).first().getText());
+
+ openTestURL();
+ // no errors and page fully reloaded
+ assertTrue($(LabelElement.class).all().isEmpty());
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java b/uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java
new file mode 100644
index 0000000000..47e86d9039
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2014 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 static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.tb3.newelements.FixedNotificationElement;
+
+public class VaadinSessionAttributeTest extends MultiBrowserTest {
+
+ @Test
+ public void testSessionAttribute() {
+ openTestURL();
+ $(ButtonElement.class).first().click();
+ assertEquals("notification does not contain suitable text", "42 & 84",
+ $(FixedNotificationElement.class).first().getCaption());
+ }
+
+}