summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-04-25 14:31:58 +0300
committerLeif Åstrand <leif@vaadin.com>2012-04-25 14:31:58 +0300
commit46c74e7362271ccbcf54c506657d8c0846a61858 (patch)
treebc691728f3de18fbbf18182d660fa56b63e141b9 /tests
parentfa3754c13dced327c780445b46954e5ec61989f3 (diff)
parent032f760be4c0bb84ea35a3faabcac721a764a56f (diff)
downloadvaadin-framework-46c74e7362271ccbcf54c506657d8c0846a61858.tar.gz
vaadin-framework-46c74e7362271ccbcf54c506657d8c0846a61858.zip
Merge remote branch 'origin/6.8'
Conflicts: src/com/vaadin/terminal/gwt/client/ApplicationConnection.java src/com/vaadin/terminal/gwt/client/HistoryImplIEVaadin.java src/com/vaadin/terminal/gwt/client/Util.java src/com/vaadin/terminal/gwt/client/ui/FocusableScrollPanel.java src/com/vaadin/terminal/gwt/client/ui/UploadIFrameOnloadStrategy.java src/com/vaadin/terminal/gwt/client/ui/UploadIFrameOnloadStrategyIE.java src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java src/com/vaadin/terminal/gwt/client/ui/VTextField.java src/com/vaadin/terminal/gwt/client/ui/VVideo.java src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
Diffstat (limited to 'tests')
-rw-r--r--tests/testbench/com/vaadin/tests/components/TouchScrollables.java267
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html42
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java81
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.html32
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.java58
5 files changed, 448 insertions, 32 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java
new file mode 100644
index 0000000000..636bddead8
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java
@@ -0,0 +1,267 @@
+package com.vaadin.tests.components;
+
+import java.util.Collection;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.DataBoundTransferable;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropHandler;
+import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
+import com.vaadin.event.dd.acceptcriteria.SourceIs;
+import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
+import com.vaadin.tests.util.Person;
+import com.vaadin.tests.util.PersonContainer;
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.Table;
+
+public class TouchScrollables extends TestBase {
+ java.util.Random r = new java.util.Random(1);
+
+ private HorizontalLayout testSelector;
+
+ @Override
+ public void setup() {
+ testSelector = new HorizontalLayout();
+ getLayout().addComponent(testSelector);
+
+ CssLayout cssLayout = new CssLayout();
+ final Table table = new Table();
+
+ Button button = new Button("Toggle lazyloading");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (table.getCacheRate() == 100) {
+ table.setCacheRate(2);
+ table.setPageLength(15);
+ } else {
+ table.setCacheRate(100);
+ table.setHeight("400px");
+ }
+ }
+ });
+ cssLayout.addComponent(button);
+
+ button = new Button("Toggle selectable");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.setSelectable(!table.isSelectable());
+ }
+ });
+ cssLayout.addComponent(button);
+
+ table.addContainerProperty("foo", String.class, "bar");
+ table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);
+ for (int i = 0; i < 1000; i++) {
+ table.addItem();
+ }
+ cssLayout.addComponent(table);
+ cssLayout.setCaption("Table");
+
+ addTest(cssLayout);
+
+ cssLayout = new CssLayout();
+ cssLayout.setCaption("Panel");
+
+ final Panel p = new Panel();
+ p.setHeight("400px");
+ p.setCaption("Panel");
+ Label l50 = null;
+ for (int i = 0; i < 100; i++) {
+ Label c = new Label("Label" + i);
+ p.addComponent(c);
+ if (i == 50) {
+ l50 = c;
+ }
+ }
+
+ final Label l = l50;
+ button = new Button("Scroll to label 50", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ getLayout().getRoot().scrollIntoView(l);
+ }
+ });
+ cssLayout.addComponent(button);
+ button = new Button("Scroll to 100px", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ p.setScrollTop(100);
+ }
+ });
+ cssLayout.addComponent(button);
+ cssLayout.addComponent(p);
+
+ addTest(cssLayout);
+
+ TestUtils
+ .injectCSS(
+ getLayout().getRoot(),
+ "body * {-webkit-user-select: none;} .v-table-row-drag-middle .v-table-cell-content {"
+ + " background-color: inherit ; border-bottom: 1px solid cyan;"
+ + "}"
+ + ".v-table-row-drag-middle .v-table-cell-wrapper {"
+ + " margin-bottom: -1px;" + "}" + ""
+
+ );
+
+ addDDSortableTable();
+
+ }
+
+ private void addDDSortableTable() {
+ final Table table;
+ table = new Table();
+ table.setCaption("DD sortable table with context menus");
+ // table.setWidth("100%");
+ table.setPageLength(10);
+ table.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ table.setSelectable(true);
+ table.setMultiSelect(true);
+
+ table.addActionHandler(new Handler() {
+
+ Action[] actions = new Action[] { new Action("FOO"),
+ new Action("BAR"), new Action("CAR") };
+
+ public Action[] getActions(Object target, Object sender) {
+ return actions;
+ }
+
+ public void handleAction(Action action, Object sender, Object target) {
+ getLayout().getRoot().showNotification(action.getCaption());
+
+ }
+ });
+
+ populateTable(table);
+
+ /*
+ * Make table rows draggable
+ */
+ table.setDragMode(Table.TableDragMode.ROW);
+
+ table.setDropHandler(new DropHandler() {
+ // accept only drags from this table
+ AcceptCriterion crit = new SourceIs(table);
+
+ public AcceptCriterion getAcceptCriterion() {
+ return crit;
+ }
+
+ public void drop(DragAndDropEvent dropEvent) {
+ AbstractSelectTargetDetails dropTargetData = (AbstractSelectTargetDetails) dropEvent
+ .getTargetDetails();
+ DataBoundTransferable transferable = (DataBoundTransferable) dropEvent
+ .getTransferable();
+ Object itemIdOver = dropTargetData.getItemIdOver();
+ Object itemId = transferable.getItemId();
+ if (itemId == null || itemIdOver == null
+ || itemId.equals(itemIdOver)) {
+ return; // no move happened
+ }
+
+ // IndexedContainer goodies... (hint: don't use it in real apps)
+ IndexedContainer containerDataSource = (IndexedContainer) table
+ .getContainerDataSource();
+ int newIndex = containerDataSource.indexOfId(itemIdOver) - 1;
+ if (dropTargetData.getDropLocation() != VerticalDropLocation.TOP) {
+ newIndex++;
+ }
+ if (newIndex < 0) {
+ newIndex = 0;
+ }
+ Object idAfter = containerDataSource.getIdByIndex(newIndex);
+ Collection<?> selections = (Collection<?>) table.getValue();
+ if (selections != null && selections.contains(itemId)) {
+ // dragged a selected item, if multiple rows selected, drag
+ // them too (functionality similar to apple mail)
+ for (Object object : selections) {
+ moveAfter(containerDataSource, object, idAfter);
+ }
+
+ } else {
+ // move just the dragged row, not considering selection at
+ // all
+ moveAfter(containerDataSource, itemId, idAfter);
+ }
+
+ }
+
+ private void moveAfter(IndexedContainer containerDataSource,
+ Object itemId, Object idAfter) {
+ try {
+ IndexedContainer clone = null;
+ clone = (IndexedContainer) containerDataSource.clone();
+ containerDataSource.removeItem(itemId);
+ Item newItem = containerDataSource.addItemAfter(idAfter,
+ itemId);
+ Item item = clone.getItem(itemId);
+ for (Object propId : item.getItemPropertyIds()) {
+ newItem.getItemProperty(propId).setValue(
+ item.getItemProperty(propId).getValue());
+ }
+
+ // TODO Auto-generated method stub
+ } catch (CloneNotSupportedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ });
+ addTest(table);
+ }
+
+ private void populateTable(Table table) {
+ table.addContainerProperty("Name", String.class, "");
+ table.addContainerProperty("Weight", Integer.class, 0);
+
+ PersonContainer testData = PersonContainer.createWithTestData();
+
+ for (int i = 0; i < 40; i++) {
+ Item addItem = table.addItem("Item" + i);
+ Person p = testData.getIdByIndex(i);
+ addItem.getItemProperty("Name").setValue(
+ p.getFirstName() + " " + p.getLastName());
+ addItem.getItemProperty("Weight").setValue(50 + r.nextInt(60));
+ }
+
+ }
+
+ private Component testComponent;
+
+ private void addTest(final AbstractComponent t) {
+ Button button = new Button(t.getCaption());
+ testSelector.addComponent(button);
+ button.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ if (testComponent != null) {
+ getLayout().removeComponent(testComponent);
+ }
+ testComponent = t;
+ getLayout().addComponent(t);
+ }
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Various components and setups suitable for testing scrolling on touch devices.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html
new file mode 100644
index 0000000000..ac06706aa5
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.html
@@ -0,0 +1,42 @@
+<?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>TestCurrentPageFirstItem</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TestCurrentPageFirstItem</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/TestCurrentPageFirstItem?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTestCurrentPageFirstItem::/VHorizontalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTestCurrentPageFirstItem::/VHorizontalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTestCurrentPageFirstItem::/VHorizontalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
index 1748c27426..7fb096739a 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java
@@ -1,60 +1,77 @@
package com.vaadin.tests.components.table;
-import com.vaadin.Application;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Root.LegacyWindow;
+import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
-public class TestCurrentPageFirstItem extends Application.LegacyApplication
- implements ClickListener {
+public class TestCurrentPageFirstItem extends TestBase implements ClickListener {
private Button buttonIndex;
private Button buttonItem;
- private Table table;
+ private Table[] tables = new Table[4];
private int counter = 0;
IndexedContainer container = new IndexedContainer();
@Override
- public void init() {
- try {
- LegacyWindow main = new LegacyWindow("Table header Test");
- setMainWindow(main);
- main.setSizeFull();
- // setTheme("testtheme");
- VerticalLayout baseLayout = new VerticalLayout();
- main.setContent(baseLayout);
-
- table = new Table();
- container.addContainerProperty("row", String.class, "");
- table.setContainerDataSource(container);
- table.setWidth("100%");
- table.setPageLength(3);
- buttonIndex = new Button("Add row and select last index", this);
- buttonItem = new Button("Add row and select last item", this);
-
- baseLayout.addComponent(table);
- baseLayout.addComponent(buttonIndex);
- baseLayout.addComponent(buttonItem);
- } catch (Exception e) {
- e.printStackTrace();
+ public void setup() {
+ container.addContainerProperty("row", String.class, "");
+
+ HorizontalLayout baseLayout = new HorizontalLayout();
+ baseLayout.setHeight("115px");
+ getMainWindow().setContent(baseLayout);
+
+ for (int i = 0; i < tables.length; ++i) {
+ Table t = new Table();
+ t.setContainerDataSource(container);
+ t.setWidth("100px");
+ baseLayout.addComponent(t);
+ tables[i] = t;
}
+ tables[0].setSizeFull();
+ tables[0].setCaption("Full");
+ tables[1].setHeight("100px");
+ tables[1].setCaption("100px");
+ tables[2].setHeight("95%");
+ tables[2].setCaption("95%");
+ tables[3].setPageLength(3);
+ tables[3].setCaption("3 rows");
+
+ buttonIndex = new Button("Add row and select last index", this);
+ buttonItem = new Button("Add row and select last item", this);
+ baseLayout.addComponent(buttonIndex);
+ baseLayout.addComponent(buttonItem);
}
public void buttonClick(ClickEvent event) {
Item item = container.addItem(++counter);
item.getItemProperty("row").setValue(counter + "");
- table.select(counter);
- if (event.getButton() == buttonIndex) {
- table.setCurrentPageFirstItemIndex(((Container.Indexed) table
- .getContainerDataSource()).indexOfId(counter));
- } else {
- table.setCurrentPageFirstItemId(counter);
+ for (int i = 0; i < tables.length; ++i) {
+ Table t = tables[i];
+ t.select(counter);
+ if (event.getButton() == buttonIndex) {
+ t.setCurrentPageFirstItemIndex(((Container.Indexed) t
+ .getContainerDataSource()).indexOfId(counter));
+ } else {
+ t.setCurrentPageFirstItemId(counter);
+ }
}
}
+
+ @Override
+ protected String getDescription() {
+ return "Table height changes when using setCurrentPageFirstItemId";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2864;
+ }
}
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.html b/tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.html
new file mode 100644
index 0000000000..f5579c9875
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.html
@@ -0,0 +1,32 @@
+<?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>ScrollbarsInNestedTabsheets</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ScrollbarsInNestedTabsheets</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/ScrollbarsInNestedTabsheets?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runScrollbarsInNestedTabsheets::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTabsheet[0]/VTabsheetPanel[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>27,8</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>should-not-have-scrollbars</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.java b/tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.java
new file mode 100644
index 0000000000..de250539ff
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.java
@@ -0,0 +1,58 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+@SuppressWarnings("serial")
+public class ScrollbarsInNestedTabsheets extends TestBase {
+
+ @Override
+ public void setup() {
+ setTheme("chameleon");
+ final Label l = new Label("Select Sub Tab 2");
+ final TabSheet t = new TabSheet();
+ final TabSheet t2 = getTabSheet();
+ t.addTab(t2, "Main Tab");
+ addComponent(l);
+ addComponent(t);
+ }
+
+ private TabSheet getTabSheet() {
+ final TabSheet t = new TabSheet();
+ t.addTab(getDummyLayout1(), "Sub Tab 1");
+ t.addTab(getDummyLayout2(), "Sub Tab 2");
+
+ return t;
+ }
+
+ private Layout getDummyLayout1() {
+ final VerticalLayout l = new VerticalLayout();
+ l.addComponent(new DateField("Date"));
+
+ return l;
+ }
+
+ private Layout getDummyLayout2() {
+ final VerticalLayout l = new VerticalLayout();
+ l.addComponent(new DateField("Date"));
+ l.addComponent(new TextField("TextField"));
+
+ return l;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Nested tabsheets show unwanted scrollbars with Chameleon theme when the inner tabsheet is resized";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8625;
+ }
+
+} \ No newline at end of file