Browse Source

Converted LongMultiselectTest to TB4.

Change-Id: I0336929861ef0e162fab5f7ff4fee8dfe0b343b4
tags/7.4.0.beta1
Sauli Tähkäpää 9 years ago
parent
commit
b3bd445558

+ 0
- 72
uitest/src/com/vaadin/tests/components/table/LongMultiselect.html View File

@@ -1,72 +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>LongMultiselect</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">LongMultiselect</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.components.table.LongMultiselect?restartApplication</td>
<td></td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]</td>
<td>38,13</td>
</tr>
<tr>
<td>scroll</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
<td>18330</td>
</tr>
<tr>
<td>pause</td>
<td>300</td>
<td></td>
</tr>
<tr>
<td>scroll</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
<td>18330</td>
</tr>
<tr>
<td>pause</td>
<td>300</td>
<td></td>
</tr>
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[22]/domChild[0]/domChild[0]</td>
<td>41,-1823:shift</td>
</tr>
<tr>
<td>click</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]</td>
<td></td>
</tr>
<tr>
<td>screenCapture</td>
<td></td>
<td>selected-5-99</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[18]/domChild[1]/domChild[0]</td>
<td>updated</td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[19]/domChild[1]</td>
<td></td>
</tr>

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

+ 8
- 15
uitest/src/com/vaadin/tests/components/table/LongMultiselect.java View File

@@ -3,29 +3,23 @@ package com.vaadin.tests.components.table;
import java.util.Collection;

import com.vaadin.data.Property;
import com.vaadin.tests.components.TestBase;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;

public class LongMultiselect extends TestBase {
public class LongMultiselect extends AbstractTestUI {

private enum ItemProperty {
COLUMN1, COLUMN2
}

@Override
protected void setup() {
VerticalLayout layout = generateLayout();
addComponent(layout);
layout.setSizeFull();
}

private VerticalLayout generateLayout() {
VerticalLayout layout = new VerticalLayout();

protected void setup(VaadinRequest request) {
final Table table = new Table("Ticket #8264 table");
layout.addComponent(table);
addComponent(table);

table.setWidth("200px");
table.setHeight("170px");
table.setSelectable(true);
@@ -40,7 +34,7 @@ public class LongMultiselect extends TestBase {
}

// Add action button
layout.addComponent(new Button("Do It", new Button.ClickListener() {
addComponent(new Button("Do It", new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
// Set ItemProperty.COLUMN2 for all selected values of table
@@ -57,11 +51,10 @@ public class LongMultiselect extends TestBase {
}
}));

return layout;
}

@Override
protected String getDescription() {
protected String getTestDescription() {
return "Multiselecting 94 rows (from \"item 5\" to \"item 98\") and modifying second column of each row selected (press Do It). This should work (update the 2nd column) and not cause JS exception.";
}


+ 81
- 0
uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java View File

@@ -0,0 +1,81 @@
package com.vaadin.tests.components.table;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedCondition;

import java.util.List;
import java.util.NoSuchElementException;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class LongMultiselectTest extends MultiBrowserTest {

private int ROWCOUNT = 100;
private int FIRSTSELECTEDROW = 4;
private int LASTSELECTEDROW = 97;

@Override
public List<DesiredCapabilities> getBrowsersToTest() {
return getBrowsersSupportingShiftClick();
}

@Override
protected boolean requireWindowFocusForIE() {
return true;
}

@Test
public void selectedRowsAreUpdated() throws InterruptedException {
openTestURL();

selectRows();
$(ButtonElement.class).first().click();

TableElement table = getTable();
assertThat(table.getCell(LASTSELECTEDROW, 1).getText(), is("updated"));
assertThat(table.getCell(LASTSELECTEDROW-1, 1).getText(), is("updated"));
}

private void selectRows() {
TableElement table = getTable();
table.getCell(FIRSTSELECTEDROW, 0).click();

scrollToBottom();

new Actions(getDriver()).keyDown(Keys.SHIFT).click(getTable().getCell(LASTSELECTEDROW, 0)).keyUp(Keys.SHIFT)
.build().perform();
}

private TableElement getTable() {
return $(TableElement.class).first();
}

private void scrollToBottom() {
testBenchElement(getTable().findElement(By.className("v-scrollable"))).scroll(ROWCOUNT * 30);

waitUntilRowIsVisible(LASTSELECTEDROW);
}

private void waitUntilRowIsVisible(final int row) {
waitUntil(new ExpectedCondition<Object>() {
@Override
public Object apply(WebDriver input) {
try {
return getTable().getCell(row, 0) != null;
} catch (NoSuchElementException e) {
return false;
}
}
});
}

}

+ 12
- 0
uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java View File

@@ -50,6 +50,18 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration {
return browsers;
}


protected List<DesiredCapabilities> getBrowsersSupportingShiftClick() {
List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers());

//IE supports shift click only when require window focus is true
browsers.remove(Browser.FIREFOX.getDesiredCapabilities());
browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());

return browsers;
}


public enum Browser {
FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI(
BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil

Loading…
Cancel
Save