浏览代码

TestBench test case for #8291

svn changeset:24289/svn branch:6.8
tags/7.0.0.beta1
Johannes Dahlström 11 年前
父节点
当前提交
c75cf3956a

+ 67
- 0
tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.html 查看文件

@@ -0,0 +1,67 @@
<?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="" />
<title>TableReduceContainerSize</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TableReduceContainerSize</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/TableReduceContainerSize?restartApplication</td>
<td></td>
</tr>
<tr>
<td>scroll</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
<td>19700</td>
</tr>
<tr>
<td>pause</td>
<td>300</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
<td>Index: *</td>
</tr>
<tr>
<td>click</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
<td></td>
</tr>
<tr>
<td>scroll</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
<td>19700</td>
</tr>
<tr>
<td>pause</td>
<td>300</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td>
<td>Index: *</td>
</tr>

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

tests/testbench/com/vaadin/tests/tickets/Ticket8291.java → tests/testbench/com/vaadin/tests/components/table/TableReduceContainerSize.java 查看文件

@@ -1,28 +1,28 @@
package com.vaadin.tests.tickets;
package com.vaadin.tests.components.table;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.vaadin.Application;
import com.vaadin.data.Container.Filter;
import com.vaadin.data.Item;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

/**
* Test for #8291 and #7666: NegativeArraySizeException when Table scrolled to
* the end and its size reduced.
*/
public class Ticket8291 extends Application {
public class TableReduceContainerSize extends TestBase {

@Override
public void init() {
setMainWindow(new Window("", new TestView()));
protected void setup() {
addComponent(new TestView());
}

private static class DecimateFilter implements Filter {
@@ -59,25 +59,41 @@ public class Ticket8291 extends Application {
};
table.setContainerDataSource(container);
addComponent(table);
final Label label = new Label();
addComponent(label);
Button button = new Button("Click");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
reduceData = !reduceData;
table.refreshRowCache();
try {
reduceData = !reduceData;
table.refreshRowCache();
label.setValue("Index: "
+ table.getCurrentPageFirstItemIndex());
} catch (Exception e) {
label.setValue("Exception: "
+ e.getClass().getSimpleName());
}
}
});
addComponent(button);
Button button2 = new Button("Filter");
button2.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
if (filter != null) {
container.removeAllContainerFilters();
filter = null;
} else {
filter = new DecimateFilter();
container.addContainerFilter(filter);
try {
if (filter != null) {
container.removeAllContainerFilters();
filter = null;
} else {
filter = new DecimateFilter();
container.addContainerFilter(filter);
}
table.refreshRowCache();
label.setValue("Index: "
+ table.getCurrentPageFirstItemIndex());
} catch (Exception e) {
label.setValue("Exception: "
+ e.getClass().getSimpleName());
}
table.refreshRowCache();
}
});
addComponent(button2);
@@ -118,4 +134,14 @@ public class Ticket8291 extends Application {

}

@Override
protected String getDescription() {
return "Table throws NegativeArraySizeException if container size is reduced to less than current scroll position";
}

@Override
protected Integer getTicketNumber() {
return 8291;
}

}

正在加载...
取消
保存