diff options
author | Miki <miki@vaadin.com> | 2015-02-13 14:16:39 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-02-18 07:45:18 +0000 |
commit | d23382ad25b0a9f1ab1bf864f8fd3746e5b1c320 (patch) | |
tree | 108db32ae1e3059dcaae6a4db0fb31d2d0e7845e | |
parent | 1321b9f242d5355ed8d570b40d1f655a2b5ad14d (diff) | |
download | vaadin-framework-d23382ad25b0a9f1ab1bf864f8fd3746e5b1c320.tar.gz vaadin-framework-d23382ad25b0a9f1ab1bf864f8fd3746e5b1c320.zip |
Migrated tb2 tests to tb4
DeploymentConfigurationTest
OldUIOnReloadTest
ErrorInUnloadEventTest
VaadinSessionAttributeTest
Change-Id: I2ccddf4d2bd01f4532dda79698e6be71b3b1a9f5
10 files changed, 238 insertions, 242 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()); + } + +} diff --git a/uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html b/uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html deleted file mode 100644 index 2bdb7c79a5..0000000000 --- a/uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html +++ /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 index 33fc46f060..0000000000 --- a/uitest/tb2/com/vaadin/tests/application/DetachOldUIOnReload.html +++ /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 index ee200d7f5c..0000000000 --- a/uitest/tb2/com/vaadin/tests/application/ErrorInUnloadEvent.html +++ /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 index 150ab3ff3d..0000000000 --- a/uitest/tb2/com/vaadin/tests/application/VaadinSessionAttribute.html +++ /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&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 & 84</td> -</tr> -</tbody></table> -</body> -</html> |