From 5cab6f2d8c46042896fb423f61643d7a89041d76 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 13 Jul 2015 17:26:20 +0300 Subject: [PATCH] Convert OutOfSyncTest from TB2 to TB4 This behaviour was changed in patch for #12909 Change-Id: I616f8bd8b486b402a204056d0f76b4be6a7a15e4 --- .../vaadin/tests/components/OutOfSync.java | 55 ++++++++++++ .../tests/components/OutOfSyncTest.java | 89 +++++++++---------- .../tests/components/OutOfSyncTest.html | 38 -------- 3 files changed, 96 insertions(+), 86 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/OutOfSync.java delete mode 100644 uitest/tb2/com/vaadin/tests/components/OutOfSyncTest.html 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()); } } diff --git a/uitest/tb2/com/vaadin/tests/components/OutOfSyncTest.html b/uitest/tb2/com/vaadin/tests/components/OutOfSyncTest.html deleted file mode 100644 index 4828069e2a..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/OutOfSyncTest.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/OutOfSyncTest?restartApplication
pause1000
clickvaadin=runOutOfSyncTest::/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runOutOfSyncTest::/VButton[0]
- - -- 2.39.5