summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-07-13 17:26:20 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-07-13 18:26:32 +0300
commit4113062fc3c447debf7b7ea10c22b886dcf651c2 (patch)
tree35e0921e49b54cd4987b76dd105f4443d2582cb7 /uitest/src/com/vaadin/tests/components
parent96e10ed8be9ec1e694001098584361e43eb35af2 (diff)
downloadvaadin-framework-4113062fc3c447debf7b7ea10c22b886dcf651c2.tar.gz
vaadin-framework-4113062fc3c447debf7b7ea10c22b886dcf651c2.zip
Convert OutOfSyncTest from TB2 to TB4
This behaviour was changed in patch for #12909 Change-Id: If39839456608dff94125456c283ee2eec39f15c3
Diffstat (limited to 'uitest/src/com/vaadin/tests/components')
-rw-r--r--uitest/src/com/vaadin/tests/components/OutOfSync.java55
-rw-r--r--uitest/src/com/vaadin/tests/components/OutOfSyncTest.java89
2 files changed, 96 insertions, 48 deletions
diff --git a/uitest/src/com/vaadin/tests/components/OutOfSync.java b/uitest/src/com/vaadin/tests/components/OutOfSync.java
new file mode 100644
index 0000000000..8cefffc9d1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/OutOfSync.java
@@ -0,0 +1,55 @@
+package com.vaadin.tests.components;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Notification;
+
+public class OutOfSync extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Button b = new Button("Click me after 1s to be out of sync");
+ b.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Notification.show("This code will never be reached");
+ }
+ });
+ setContent(b);
+ Thread t = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ // Remove button but prevent repaint -> causes out of sync
+ // issues
+ getSession().lock();
+ try {
+ setContent(null);
+ getConnectorTracker().markClean(OutOfSync.this);
+ } finally {
+ getSession().unlock();
+ }
+ }
+ });
+ t.start();
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10780;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java b/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java
index 0efb519e8d..c6bab3c9b9 100644
--- a/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java
+++ b/uitest/src/com/vaadin/tests/components/OutOfSyncTest.java
@@ -1,55 +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.components;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Notification;
-
-public class OutOfSyncTest extends AbstractTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- Button b = new Button("Click me after 1s to be out of sync");
- b.addClickListener(new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- Notification.show("This code will never be reached");
- }
- });
- setContent(b);
- Thread t = new Thread(new Runnable() {
-
- @Override
- public void run() {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- // Remove button but prevent repaint -> causes out of sync
- // issues
- getSession().lock();
- try {
- setContent(null);
- getConnectorTracker().markClean(OutOfSyncTest.this);
- } finally {
- getSession().unlock();
- }
- }
- });
- t.start();
- }
+import org.junit.Assert;
+import org.junit.Test;
- @Override
- protected String getTestDescription() {
- return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
- }
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class OutOfSyncTest extends MultiBrowserTest {
+
+ @Test
+ public void testClientResync() throws InterruptedException {
+ openTestURL();
+
+ // Wait for server to get rid of the Button
+ sleep(1000);
+
+ // On the first round-trip after the component has been removed, the
+ // server assumes the client will remove the button. How ever (to force
+ // it to be out of sync) the test UI calls markClean() on the Button to
+ // make it not update with the response.
+ $(ButtonElement.class).first().click();
+ Assert.assertTrue(
+ "Button should not have disappeared on the first click.",
+ $(ButtonElement.class).exists());
- @Override
- protected Integer getTicketNumber() {
- return 10780;
+ // Truly out of sync, full resync is forced.
+ $(ButtonElement.class).first().click();
+ Assert.assertFalse("Button should disappear with the second click.",
+ $(ButtonElement.class).exists());
}
}