Browse Source

Convert OutOfSyncTest from TB2 to TB4

This behaviour was changed in patch for #12909

Change-Id: If39839456608dff94125456c283ee2eec39f15c3
tags/7.6.0.alpha3^2
Teemu Suo-Anttila 8 years ago
parent
commit
4113062fc3

+ 55
- 0
uitest/src/com/vaadin/tests/components/OutOfSync.java View File

@@ -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;
}

}

+ 41
- 48
uitest/src/com/vaadin/tests/components/OutOfSyncTest.java View File

@@ -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());
}

}

+ 0
- 38
uitest/tb2/com/vaadin/tests/components/OutOfSyncTest.html View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://localhost:8888/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/OutOfSyncTest?restartApplication</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>vaadin=runOutOfSyncTest::/VButton[0]/domChild[0]/domChild[0]</td>
<td></td>
</tr>
<!--Out of sync occured -> the button should be removed-->
<tr>
<td>assertElementNotPresent</td>
<td>vaadin=runOutOfSyncTest::/VButton[0]</td>
<td></td>
</tr>

</tbody></table>
</body>
</html>

Loading…
Cancel
Save