summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-09-07 14:01:18 +0300
committerArtur Signell <artur@vaadin.com>2015-09-07 15:06:48 +0300
commit91800a4420d4ce1afc6904f0e77bd1e170cee763 (patch)
tree6c675198e7d8dd8ac7153104210c922d77fc4fbc /uitest
parente54434a93266757616be1362fa5475fc5431c48f (diff)
downloadvaadin-framework-91800a4420d4ce1afc6904f0e77bd1e170cee763.tar.gz
vaadin-framework-91800a4420d4ce1afc6904f0e77bd1e170cee763.zip
Test to validate that resynchronize/repaintAll actually resynchronizes
Change-Id: Ib68f73e01fc0f545e0042a358d95a2b7185476ac
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/application/ResynchronizeUI.java39
-rw-r--r--uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java65
2 files changed, 104 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java
new file mode 100644
index 0000000000..62331ec95e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java
@@ -0,0 +1,39 @@
+/*
+ * 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 com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class ResynchronizeUI extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Button b = new Button("Resynchronize", new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ // Theme change is currently the only operation which always
+ // does resynchronize
+ setTheme("runo");
+ log("Set theme to runo");
+ }
+ });
+ addComponent(b);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java
new file mode 100644
index 0000000000..4dd8292e23
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.Collections;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.StaleElementReferenceException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ResynchronizeUITest extends SingleBrowserTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // PhantomJS does not send onload events for styles
+ return Collections.singletonList(Browser.FIREFOX
+ .getDesiredCapabilities());
+ }
+
+ @Test
+ public void ensureResynchronizeRecreatesDOM() {
+ openTestURL();
+ ButtonElement button = $(ButtonElement.class).first();
+ button.click();
+ // Click causes repaint, after this the old button element should no
+ // longer be available
+ // Ensure that the theme has changed
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ WebElement app = input.findElement(By.className("v-app"));
+ return hasCssClass(app, "runo");
+ }
+ });
+ try {
+ button.click();
+ Assert.fail("The old button element should have been removed by the click and replaced by a new one.");
+ } catch (StaleElementReferenceException e) {
+ // This is what should happen
+ }
+ }
+}