]> source.dussan.org Git - vaadin-framework.git/commitdiff
Migrated tb2 tests to tb4
authorMiki <miki@vaadin.com>
Fri, 13 Feb 2015 12:16:39 +0000 (14:16 +0200)
committerVaadin Code Review <review@vaadin.com>
Wed, 18 Feb 2015 07:45:18 +0000 (07:45 +0000)
DeploymentConfigurationTest
OldUIOnReloadTest
ErrorInUnloadEventTest
VaadinSessionAttributeTest

Change-Id: I2ccddf4d2bd01f4532dda79698e6be71b3b1a9f5

uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java
uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java
uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java [new file with mode: 0644]
uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html [deleted file]
uitest/tb2/com/vaadin/tests/application/DetachOldUIOnReload.html [deleted file]
uitest/tb2/com/vaadin/tests/application/ErrorInUnloadEvent.html [deleted file]
uitest/tb2/com/vaadin/tests/application/VaadinSessionAttribute.html [deleted file]

diff --git a/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java b/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java
new file mode 100644 (file)
index 0000000..9c95479
--- /dev/null
@@ -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:";
+    }
+}
index 799622b31d99c34caeb888d67f82d8cffcc63791..9a51980c9ec46f6d5a19b4d6f4e5491a0e354707 100644 (file)
@@ -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());
     }
+
 }
index 8cb670c0fb2f5f71cc1071a5924162a35e246616..a7c9239fae9fc1d1d9e10498b136dc8cbc3b2aa0 100644 (file)
@@ -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 (file)
index 0000000..1e156c3
--- /dev/null
@@ -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 (file)
index 0000000..fa316c6
--- /dev/null
@@ -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 (file)
index 0000000..47e86d9
--- /dev/null
@@ -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());
+    }
+
+}
diff --git a/uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html b/uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html
deleted file mode 100644 (file)
index 2bdb7c7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?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://localhost:8070/" />
-<title>DeploymentConfigurationTest</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">DeploymentConfigurationTest</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.application.DeploymentConfigurationTest?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextPresent</td>
-       <td>exact:closeIdleSessions: true</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextPresent</td>
-       <td>exact:productionMode: false</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextPresent</td>
-       <td>exact:testParam: 42</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextPresent</td>
-       <td>exact:heartbeatInterval: 301</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextPresent</td>
-       <td>exact:resourceCacheTime: 3601</td>
-       <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/tb2/com/vaadin/tests/application/DetachOldUIOnReload.html b/uitest/tb2/com/vaadin/tests/application/DetachOldUIOnReload.html
deleted file mode 100644 (file)
index 33fc46f..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?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>click</td>
-       <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</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>click</td>
-       <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/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>click</td>
-       <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</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/tb2/com/vaadin/tests/application/ErrorInUnloadEvent.html b/uitest/tb2/com/vaadin/tests/application/ErrorInUnloadEvent.html
deleted file mode 100644 (file)
index ee200d7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?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/tb2/com/vaadin/tests/application/VaadinSessionAttribute.html b/uitest/tb2/com/vaadin/tests/application/VaadinSessionAttribute.html
deleted file mode 100644 (file)
index 150ab3f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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.VaadinSessionAttribute?restartApplication&amp;attachMainFirst</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runcomvaadintestsapplicationVaadinSessionAttribute::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>//body/div[2]//h1</td>
-       <td>42 &amp; 84</td>
-</tr>
-</tbody></table>
-</body>
-</html>