aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin
diff options
context:
space:
mode:
authorJonatan Kronqvist <jonatan@vaadin.com>2014-04-14 11:53:11 +0300
committerJonatan Kronqvist <jonatan@vaadin.com>2014-04-14 12:06:05 +0300
commit416e2f97bcaf93e4d2a782149a963fca95b8400e (patch)
treeeac6d22107b7c2d7bf6371e5278078f02bb860e9 /uitest/src/com/vaadin
parentd2e24feb09ccba7f3a2f253687488774af2bc340 (diff)
parenteda9edcbde781d29ff5939defb61ba5fb159e206 (diff)
downloadvaadin-framework-416e2f97bcaf93e4d2a782149a963fca95b8400e.tar.gz
vaadin-framework-416e2f97bcaf93e4d2a782149a963fca95b8400e.zip
Merge branch 'master' into 7.2
72d0aa0 Update Window Javadoc based on 7.2 API review changes ee203f5 Apply abstract ordered layout settings for replaced component (#13568) 02998d8 Updated Window API based on 7.2 API review cd94b21 Discourage use of setNeedsLayout while a layout is running (#13542) f374bc7 Make ComboBox always immediate (#4054) aec102a Update 3rd party license information (#13449) 013d32d Remove old widget from tab content on replace (#12931). 3d0ff32 Prevent duplicate detach() calls with push (#13261) a452bad Refactor VaadinPortletRequest extending. (#13551) 55dfd29 Prevent duplicate session destroy events (#12612) 2067d4e Don't allocate unnecessary memory for empty array of Objects in MethodProperty (#10446). 00a9af5 Refactor PushConfigurationTest. Merge: no Change-Id: I6563769a77f91a68cfeadcb3306dd71fe431863c
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java72
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java48
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java58
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java57
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurationTest.java138
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java58
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurator.java1
7 files changed, 329 insertions, 103 deletions
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java
new file mode 100644
index 0000000000..da0ad3685a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2000-2013 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.components.accordion;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Accordion;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Test UI for Accordion: old widget should be removed from the tab.
+ *
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class AccordionAddTab extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Accordion tabs = new Accordion();
+ addComponent(tabs);
+ tabs.setHeight(500, Unit.PIXELS);
+ Button remove = new Button("Remove 'First'");
+ final Tab me = tabs.addTab(addTab("First"));
+ remove.addClickListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ tabs.removeTab(me);
+ Tab tab = tabs.addTab(addTab("Next"));
+ tabs.setSelectedTab(tab);
+ }
+ });
+ addComponent(remove);
+ }
+
+ private Component addTab(String tag) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.addComponent(new Label("On tab: " + tag));
+ return new Panel(tag, layout);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Remove previous widget in the accordion tab when content is replaced";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11367;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java
new file mode 100644
index 0000000000..68aa61cc87
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2013 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.components.accordion;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for Accordion : replace widget in tab should remove old widget.
+ *
+ * @since 7.2
+ * @author Vaadin Ltd
+ */
+public class AccordionAddTabTest extends MultiBrowserTest {
+
+ @Test
+ public void testRemoveAndAdd() {
+ openTestURL();
+
+ WebElement button = driver.findElement(By.className("v-button"));
+ button.click();
+
+ List<WebElement> panels = driver.findElements(By.className("v-panel"));
+
+ Assert.assertEquals("Found two widgets inside one tab after "
+ + "subsequent tab removal and addition", 1, panels.size());
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java
new file mode 100644
index 0000000000..c0503d5240
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2013 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.push;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.Select;
+
+public class PushConfigurationLongPollingTest extends PushConfigurationTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsers = super.getBrowsersToTest();
+
+ browsers.remove(Browser.IE8.getDesiredCapabilities());
+
+ return browsers;
+ }
+
+ @Test
+ public void testLongPolling() throws InterruptedException {
+ new Select(getTransportSelect()).selectByVisibleText("LONG_POLLING");
+ new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+
+ assertThat(getStatusText(),
+ containsString("fallbackTransport: long-polling"));
+ assertThat(getStatusText(), containsString("transport: long-polling"));
+
+ waitForServerCounterToUpdate();
+
+ // Use debug console to verify we used the correct transport type
+ assertThat(
+ driver.getPageSource(),
+ containsString("Push connection established using long-polling"));
+
+ new Select(getPushModeSelect()).selectByVisibleText("DISABLED");
+
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java
new file mode 100644
index 0000000000..46fcc5f44b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-2013 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.push;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.Select;
+
+public class PushConfigurationStreamingTest extends PushConfigurationTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ List<DesiredCapabilities> browsers = super.getBrowsersToTest();
+
+ browsers.remove(Browser.IE8.getDesiredCapabilities());
+
+ return browsers;
+ }
+
+ @Test
+ public void testStreaming() throws InterruptedException {
+ new Select(getTransportSelect()).selectByVisibleText("STREAMING");
+ new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+
+ assertThat(getStatusText(),
+ containsString("fallbackTransport: long-polling"));
+ assertThat(getStatusText(), containsString("transport: streaming"));
+
+ waitForServerCounterToUpdate();
+
+ // Use debug console to verify we used the correct transport type
+ assertThat(
+ driver.getPageSource(),
+ not(containsString("Push connection established using websocket")));
+ assertThat(driver.getPageSource(),
+ containsString("Push connection established using streaming"));
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
index d7ffb47bbc..20399fc67e 100644
--- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
@@ -17,139 +17,71 @@ package com.vaadin.tests.push;
import static org.junit.Assert.assertEquals;
-import org.junit.Assert;
-import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.Select;
-import com.vaadin.tests.tb3.WebsocketTest;
+import com.vaadin.tests.annotations.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
-public class PushConfigurationTest extends WebsocketTest {
+@TestCategory("push")
+abstract class PushConfigurationTest extends MultiBrowserTest {
- @Test
- public void testWebsocketAndStreaming() throws InterruptedException {
- setDebug(true);
- openTestURL();
- // Websocket
- verifyPushDisabled();
- new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET");
- new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
- Assert.assertTrue(vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
- .getText()
- .matches(
- "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: websocket[\\s\\S]*$"));
- int counter = getServerCounter();
- final int waitCounter = counter + 2;
- waitUntil(new ExpectedCondition<Boolean>() {
-
- @Override
- public Boolean apply(WebDriver input) {
- return (getServerCounter() >= waitCounter);
- }
- });
-
- // Use debug console to verify we used the correct transport type
- Assert.assertTrue(driver.getPageSource().contains(
- "Push connection established using websocket"));
- Assert.assertFalse(driver.getPageSource().contains(
- "Push connection established using streaming"));
-
- new Select(getPushModeSelect()).selectByVisibleText("DISABLED");
-
- // Streaming
- driver.get(getTestUrl());
- verifyPushDisabled();
-
- new Select(getTransportSelect()).selectByVisibleText("STREAMING");
- new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
- Assert.assertTrue(vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
- .getText()
- .matches(
- "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: streaming[\\s\\S]*$"));
-
- counter = getServerCounter();
- for (int second = 0;; second++) {
- if (second >= 5) {
- Assert.fail("timeout");
- }
- if (getServerCounter() >= (counter + 2)) {
- break;
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
-
- // Use debug console to verify we used the correct transport type
- Assert.assertFalse(driver.getPageSource().contains(
- "Push connection established using websocket"));
- Assert.assertTrue(driver.getPageSource().contains(
- "Push connection established using streaming"));
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ disablePush();
}
- @Test
- public void testLongPolling() throws InterruptedException {
- setDebug(true);
- openTestURL();
- verifyPushDisabled();
- new Select(getTransportSelect()).selectByVisibleText("LONG_POLLING");
- new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
- Assert.assertTrue(vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
- .getText()
- .matches(
- "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: long-polling[\\s\\S]*$"));
- int counter = getServerCounter();
- final int waitCounter = counter + 2;
- waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ protected String getDeploymentPath() {
+ return "/run/" + PushConfiguration.class.getCanonicalName()
+ + "?restartApplication&debug";
+ }
- @Override
- public Boolean apply(WebDriver input) {
- return (getServerCounter() >= waitCounter);
- }
- });
+ protected String getStatusText() {
+ WebElement statusLabel = vaadinElementById("status");
- // Use debug console to verify we used the correct transport type
- Assert.assertTrue(driver.getPageSource().contains(
- "Push connection established using long-polling"));
- Assert.assertFalse(driver.getPageSource().contains(
- "Push connection established using streaming"));
+ return statusLabel.getText();
+ }
+ protected void disablePush() throws InterruptedException {
new Select(getPushModeSelect()).selectByVisibleText("DISABLED");
- }
-
- /**
- * Verifies that push is currently not enabled.
- *
- * @throws InterruptedException
- */
- private void verifyPushDisabled() throws InterruptedException {
int counter = getServerCounter();
sleep(2000);
assertEquals("Server count changed without push enabled", counter,
getServerCounter());
}
- private WebElement getPushModeSelect() {
+ protected WebElement getPushModeSelect() {
return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]");
}
- private WebElement getTransportSelect() {
+ protected WebElement getTransportSelect() {
return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]");
}
- private int getServerCounter() {
+ protected int getServerCounter() {
return Integer.parseInt(getServerCounterElement().getText());
}
- private WebElement getServerCounterElement() {
+ protected WebElement getServerCounterElement() {
return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]");
}
+
+ protected void waitForServerCounterToUpdate() {
+ int counter = getServerCounter();
+ final int waitCounter = counter + 2;
+ waitUntil(new ExpectedCondition<Boolean>() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ return (getServerCounter() >= waitCounter);
+ }
+ });
+ }
} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java
new file mode 100644
index 0000000000..c8308e72f1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2000-2013 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.push;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.Select;
+
+public class PushConfigurationWebSocketTest extends PushConfigurationTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+
+ List<DesiredCapabilities> browsers = super.getBrowsersToTest();
+ browsers.remove(Browser.IE8.getDesiredCapabilities());
+ browsers.remove(Browser.IE9.getDesiredCapabilities());
+
+ return browsers;
+ }
+
+ @Test
+ public void testWebsocket() throws InterruptedException {
+ new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET");
+ new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+
+ assertThat(getStatusText(),
+ containsString("fallbackTransport: long-polling"));
+ assertThat(getStatusText(), containsString("transport: websocket"));
+
+ waitForServerCounterToUpdate();
+
+ // Use debug console to verify we used the correct transport type
+ assertThat(driver.getPageSource(),
+ containsString("Push connection established using websocket"));
+ assertThat(
+ driver.getPageSource(),
+ not(containsString("Push connection established using streaming")));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurator.java b/uitest/src/com/vaadin/tests/push/PushConfigurator.java
index 6528366b59..6dbe130b73 100644
--- a/uitest/src/com/vaadin/tests/push/PushConfigurator.java
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurator.java
@@ -101,6 +101,7 @@ public class PushConfigurator extends VerticalLayout {
paramValue.setDefaultComponentAlignment(Alignment.BOTTOM_RIGHT);
paramValue.addComponents(parameter, value, set);
+ status.setId("status");
vl.addComponents(pushMode, transport, fallbackTransport, paramValue,
new Label("<hr/>", ContentMode.HTML), status);
addComponent(vl);