From 6e7603f448ad63426e7e5ebbc84dc0133395ce43 Mon Sep 17 00:00:00 2001 From: Miki Date: Fri, 13 Feb 2015 14:16:39 +0200 Subject: [PATCH] Migrated tb2 tests to tb4 DeploymentConfigurationTest OldUIOnReloadTest ErrorInUnloadEventTest VaadinSessionAttributeTest Change-Id: I2ccddf4d2bd01f4532dda79698e6be71b3b1a9f5 --- .../application/DeploymentConfiguration.java | 27 ++++++ .../DeploymentConfigurationTest.java | 53 ++++++++--- .../application/DetachOldUIOnReload.java | 1 + .../application/DetachOldUIOnReloadTest.java | 85 +++++++++++++++++ .../application/ErrorInUnloadEventTest.java | 51 ++++++++++ .../VaadinSessionAttributeTest.java | 36 ++++++++ .../DeploymentConfigurationTest.html | 47 ---------- .../application/DetachOldUIOnReload.html | 92 ------------------- .../tests/application/ErrorInUnloadEvent.html | 57 ------------ .../application/VaadinSessionAttribute.html | 31 ------- 10 files changed, 238 insertions(+), 242 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java create mode 100644 uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java create mode 100644 uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java create mode 100644 uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java delete mode 100644 uitest/tb2/com/vaadin/tests/application/DeploymentConfigurationTest.html delete mode 100644 uitest/tb2/com/vaadin/tests/application/DetachOldUIOnReload.html delete mode 100644 uitest/tb2/com/vaadin/tests/application/ErrorInUnloadEvent.html delete mode 100644 uitest/tb2/com/vaadin/tests/application/VaadinSessionAttribute.html 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 texts = new ArrayList(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 getSessionMessages(boolean storeIfNeeded) { + @SuppressWarnings("unchecked") List messages = (List) 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 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 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 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 @@ - - - - - - -DeploymentConfigurationTest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DeploymentConfigurationTest
open/run/com.vaadin.tests.application.DeploymentConfigurationTest?restartApplication
assertTextPresentexact:closeIdleSessions: true
assertTextPresentexact:productionMode: false
assertTextPresentexact:testParam: 42
assertTextPresentexact:heartbeatInterval: 301
assertTextPresentexact:resourceCacheTime: 3601
- - 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 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.application.DetachOldUIOnReload?restartApplication
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]This is UI 0
open/run/com.vaadin.tests.application.DetachOldUIOnReload
clickvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_01. UI 0 has been detached
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]This is UI 1
clickAndWaitvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_02. UI 1 has been detached
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]This is UI 2
open/
open/run/com.vaadin.tests.application.DetachOldUIOnReload
clickvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_03. UI 2 has been detached
assertTextvaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]This is UI 3
- - 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 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.application.ErrorInUnloadEvent?restartApplication
mouseClickvaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Suser66,14
enterCharactervaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Susera
mouseClickvaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwd73,16
enterCharactervaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwdd
pressSpecialKeyvaadin=runcomvaadintestsapplicationErrorInUnloadEvent::PID_Spwdenter
open/run/com.vaadin.tests.application.ErrorInUnloadEvent
assertTextvaadin=runcomvaadintestsapplicationErrorInUnloadEvent::/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VLabel[0]...Title...
- - 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 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.application.VaadinSessionAttribute?restartApplication&attachMainFirst
clickvaadin=runcomvaadintestsapplicationVaadinSessionAttribute::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertText//body/div[2]//h142 & 84
- - -- 2.39.5