Skip to content

Commit

Permalink
Convert OutOfSyncTest from TB2 to TB4
Browse files Browse the repository at this point in the history
This behaviour was changed in patch for #12909

Change-Id: If39839456608dff94125456c283ee2eec39f15c3
  • Loading branch information
Teemu Suo-Anttila committed Jul 13, 2015
1 parent 96e10ed commit 4113062
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 86 deletions.
55 changes: 55 additions & 0 deletions 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;
}

}
89 changes: 41 additions & 48 deletions 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; package com.vaadin.tests.components;


import com.vaadin.server.VaadinRequest; import org.junit.Assert;
import com.vaadin.ui.Button; import org.junit.Test;
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();
}


@Override import com.vaadin.testbench.elements.ButtonElement;
protected String getTestDescription() { import com.vaadin.tests.tb3.MultiBrowserTest;
return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
} 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 // Truly out of sync, full resync is forced.
protected Integer getTicketNumber() { $(ButtonElement.class).first().click();
return 10780; Assert.assertFalse("Button should disappear with the second click.",
$(ButtonElement.class).exists());
} }


} }
38 changes: 0 additions & 38 deletions uitest/tb2/com/vaadin/tests/components/OutOfSyncTest.html

This file was deleted.

0 comments on commit 4113062

Please sign in to comment.